Package Data | |
---|---|
Maintainer Username: | vcarreira |
Maintainer Contact: | vitor.carreira@gmail.com (Vitor Carreira) |
Package Create Date: | 2016-02-12 |
Package Last Update: | 2016-02-12 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:23:40 |
Package Statistics | |
---|---|
Total Downloads: | 133 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 3 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
A simple Laravel 5 service provider for the WordsApi service.
Add the following line to the require
section of composer.json
:
{
"require": {
"vcarreira/wordsapi-laravel": "~1.0"
}
}
In /config/app.php
, add the following to providers
:
WordsApi\WordsApiServiceProvider::class,
and the following to aliases
:
'WordsApi' => WordsApi\Facades\WordsApi::class,
In order to use the service you must first get an API key from WordsAPI. By default, the package uses the following environment variables to auto-configure the service without modification:
WORDSAPI_API_KEY
To customize the configuration file, publish the package configuration using Artisan.
php artisan vendor:publish --provider="WordsApi\WordsApiServiceProvider"
Update your settings in the generated app/config/wordsapi.php
configuration file.
To use the service within your app, you need to retrieve it from the Laravel IoC
Container. The following example uses the app
helper to retrieve information about the word 'effect'.
$word = app('wordsapi')->word('effect');
var_dump($word->definitions());
var_dump($word->synonyms());
var_dump($word->rhymes());
var_dump($word->pronunciation());
If the facade is registered within the aliases
section of the application configuration, you can also use the following code:
$word = WordsApi::word('effect');
var_dump($word->definitions());
var_dump($word->synonyms());
var_dump($word->rhymes());
var_dump($word->pronunciation());
Version 1.0 does not support search requests.