Opinionated REST JSON HTTP API client for laravel
rap2hpoutre/jacky is a Laravel package for opinionated rest json http api client for laravel.
It currently has 17 GitHub stars and 4.387 downloads on Packagist (latest version v0.0.7).
Install it with composer require rap2hpoutre/jacky.
Discover more Laravel packages by rap2hpoutre
or browse all Laravel packages to compare alternatives.
Last updated
JSON API Client for Laravel and Lumen. It's basically just a Guzzle wrapper for JSON, because Guzzle does not care about JSON anymore. And you can configure your endpoints once and for all in a configuration file, could be useful if you work with different services.
Install via composer
composer require rap2hpoutre/jacky
Add Service Provider to config/app.php in providers section
Rap2hpoutre\Jacky\ServiceProvider::class,
Then add the facade in aliases section (optional)
'Jacky' => Rap2hpoutre\Jacky\Facade::class,
Publish configuration
php artisan vendor:publish
Let's say foo API returns this on GET /users/1:
{
"data": [{
"name": "John Doe",
"email": "[email protected]"
}]
}
You may get the user like this:
$user_name = Jacky::get('foo', '/users/1')->data->first()->name;
Let's say foo API returns this on GET /users/2 not found:
{
"errors": [{
"status": "404",
"title": "User not found :/"
}]
}
You may display error title like this:
use Rap2hpoutre\Jacky\Exception\Http404Exception;
try {
$user = Jacky::get('foo', '/users/1');
} catch (Http404Exception $e) {
echo $e->errors->first()->title;
}
You can learn more about configuration here