Package Data | |
---|---|
Maintainer Username: | hiddeco |
Maintainer Contact: | hello@hidde.co (Hidde Beydals) |
Package Create Date: | 2015-06-27 |
Package Last Update: | 2016-02-29 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 15:03:55 |
Package Statistics | |
---|---|
Total Downloads: | 22 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 28 |
Total Watchers: | 2 |
Total Forks: | 4 |
Total Open Issues: | 1 |
Laravel Giphy is a Giphy API wrapper for Laravel (and Lumen but ssh, don't tell anyone), providing an easy to access Giphy
facade.
To use this package without running in to trouble you will need PHP 5.5+ or HHVM 3.6+, and Composer.
Get the latest version of Laravel Giphy, add the following line to your composer.json
file
"hiddeco/laravel-giphy": "0.1.*@alpha"
Run composer update
or composer install
Register the Laravel Giphy service provider in config/app.php
by adding
'HiddeCo\Giphy\GiphyServiceProvider
to the providers key
Add the Giphy
facade to the aliases
key: 'Giphy' => 'HiddeCo\Giphy\Facades\Giphy'
The only configuration Laravel Giphy needs is a GIPHY_API_KEY
in your .env
file. A public beta key is available in the Giphy API Documentation.
Note: On Laravel it is also possible to configure Laravel Giphy by running php artisan config:publish
and adding your apiKey
to config/giphy.php
.
Giphy
Injecting Giphy
in to a controller could not have been any easier.
<?php
class GifController extends BaseController {
public function __construct(HiddeCo\Giphy\Giphy $giphy)
{
$this->giphy = $giphy;
}
public function get($id)
{
try
{
return $this->giphy->gif()->random([ 'fmt' => 'html' ]);
}
catch (\Exception $e)
{
return $e->getMessage();
}
}
}
Using this package to communicate with the Giphy API is fairly simple by using the Giphy
facade.
Do you want to find a sweet GIF based on a keyword, translate a keyword to just one GIF or just get a random GIF? It is all possible.
Searches all GIFs for the provided word or phrase and accepts 4 optional parameters as array.
Giphy::gif()->search('code', ['limit' => 10, 'offset' => 10, 'rating' => 'g', 'fmt' => 'html']);
Returns JSON meta data about a GIF by id.
Giphy::gif()->get('4hnQDVKVARZ6w');
Returns JSON meta data about mulitple GIFs by id.
Giphy::gif()->getMultiple(['4hnQDVKVARZ6w', 'Ro2MgOxH9iaVG']);
Returns a GIF from the Giphy 'translation engine', enter a keyword and get a GIF translation back. Accepts 2 optional parameters.
Giphy::gif()->translate($query, ['rating' => 'g', 'fmt' => 'html']);
Returns a random GIF, limitation is possible by using the following optional parameters.
Giphy::gif()->random(['tag' => 'cats', 'rating' => 'g', 'fmt' => 'html']);
Returns currently trending GIFs on the internet. Accepts 3 optional parameters.
Giphy::gif()->trending(['limit' => 100, 'rating' => 'pg', 'fmt' => 'html');
Giphy stickers are animated stickers (animated GIFs with transparent backgrounds).
Searches all sticker GIFs for the provided word or phrase and accepts 4 optional parameters as array.
Giphy::sticker()->search('code', ['limit' => 10, 'offset' => 10, 'rating' => 'g', 'fmt' => 'html']);
Returns a sticker GIF from the Giphy 'translation engine', enter a keyword and get a sticker GIF translation back. Accepts 2 optional parameters.
Giphy::sticker()->translate($query, ['rating' => 'g', 'fmt' => 'html']);
Returns a random sticker GIF, limitation is possible by using the following optional parameters.
Giphy::sticker()->random(['tag' => 'cats', 'rating' => 'g', 'fmt' => 'html]);
Returns currently trending sticker GIFs on the internet. Accepts 3 optional parameters.
Giphy::sticker()->trending(['limit' => 100, 'rating' => 'pg', 'fmt' => 'html']);
Laravel Giphy is licensed under the MIT License (MIT).