New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

rap2hpoutre/jacky

Opinionated REST JSON HTTP API client for laravel
4,407 17
Install
composer require rap2hpoutre/jacky
Latest Version:v0.0.7
PHP:>=5.5.0
Laravel:5
License:MIT
Last Updated:Feb 8, 2016
Links: GitHub  ·  Packagist
Maintainer: rap2hpoutre

Jacky

Packagist Software License Build Status Quality Score SensioLabsInsight

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

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

Usage

Simple example

Let's say foo API returns this on GET /users/1:

{
  "data": [{
    "name": "John Doe",
    "email": "john@example.com"
  }]
}

You may get the user like this:

$user_name = Jacky::get('foo', '/users/1')->data->first()->name;

Not found example

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;
}

Configuration

You can learn more about configuration here

Related Packages

laragear/api-manager

Manage multiple REST servers to make requests in few lines and fluently.

2,648 16
nebo15/lumen.rest

Components for fast building REST API for Lumen

3,772 1
lujo/lumen-rest

Lumen package for creating simple REST API

97 1
vinelab/http

An http library developed for the laravel framework. aliases itself as HttpClien...

308,404 57
cline/relay

A modern, attribute-driven HTTP client for PHP

11,451 0

Version History

Version Released PHP Laravel License
v0.0.7 >=5.5.0 5.* MIT
v0.0.6 >=5.5.0 5.* MIT
v0.0.5 >=5.5.0 5.* MIT
v0.0.4 >=5.5.0 5.* MIT
v0.0.3 >=5.5.0 5.* MIT