2017 © Pedro Peláez
 

library api-resource

Laravel 5 Guzzle Api Resource Package

image

media24si/api-resource

Laravel 5 Guzzle Api Resource Package

  • Wednesday, May 11, 2016
  • by BostjanOb
  • Repository
  • 1 Watchers
  • 8 Stars
  • 729 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

Api Resource

Software License, (*1)

A simple Guzzle wrapper, providing easy access to API endpoints., (*2)

For Guzzle v5.0 support use v1.0.0, (*3)

Install - Laravel

Require this package with Composer (Packagist), using the following command:, (*4)

``` bash $ composer require media24si/api-resource, (*5)


Register the ApiResourceServiceProvider to the providers array in `config/app.php`: ``` php Media24si\ApiResource\ApiResourceServiceProvider::class,

Publish vendor files (config file): ``` bash $ php artisan vendor:publish, (*6)


**Optional** Register the facade in `config/app.php`: ``` php 'Api' => Media24si\ApiResource\Facades\ApiResource::class

Install - Lumen

Require this package with Composer (Packagist), using the following command:, (*7)

``` bash $ composer require media24si/api-resource, (*8)


Register the ApiResourceServiceProvider inside `bootstrap/app.php` (Lumen): ``` php $app->register(Media24si\ApiResource\ApiResourceServiceProvider::class);

Copy the config file from the vendor vendor/media24si/api-resource/src/config/apiresrouce.php to your local config folder config/apiresource.php and enable the config inside your bootstrap/app.php (Lumen): ``` php $app->configure('apiresource');, (*9)


**Optional** Register the facade in `bootstrap/app.php` (Lumen): ``` php class_alias(Media24si\ApiResource\Facades\ApiResource::class, 'Api');

also, make sure you uncomment this line from the same file: ``` php $app->withFacades();, (*10)


## Usage You can use this package without any configuration. Just use the \Api facade in your controller (or inject Media24si\ApiResource\ApiResource in your function/controller). Call your endpoints, like you would a normal Guzzle request: ``` php \Api::get('http://httpbin.org'); // returns a response object

Config

defaults

Associative array of Request Options, that are applied to every request, created by the client. See the official manual ., (*11)

Example: ``` php 'defaults' => [ 'base_uri' => 'http://httpbin.org/'] ], (*12)

endpoints

Array of defined endpoints. Here you can define your aliases for endpoints., (*13)

Sample array: ``` php 'endpoints' => [ 'notification' => [ 'uri' => 'http://httpbin.org/notification' ], 'categories' => [ 'uri' => '/categories', // with base_uri set 'options' => [ 'query' => [ 'fields' => 'id, title' ] ] ] ], (*14)


With endpoints defined you can make simple calls. A sample would be: ``` php \Api::get('notification')

Default options can be overridden: php \Api::get('categories', ['query' => ['fields' => 'id, title, slug']]), (*15)

License

The MIT License (MIT). Please see License File for more information., (*16)

The Versions

11/05 2016

dev-master

9999999-dev https://github.com/Media24si/ApiResource

Laravel 5 Guzzle Api Resource Package

  Sources   Download

MIT

The Requires

 

laravel guzzle laravel 5 rest client

11/05 2016

v2.0.1

2.0.1.0 https://github.com/Media24si/ApiResource

Laravel 5 Guzzle Api Resource Package

  Sources   Download

MIT

The Requires

 

laravel guzzle laravel 5 rest client

02/02 2016

v2.0.0

2.0.0.0 https://github.com/Media24si/ApiResource

Laravel 5 Guzzle Api Resource Package

  Sources   Download

MIT

The Requires

 

laravel guzzle laravel 5 rest client

27/05 2015

v1.0.0

1.0.0.0 https://github.com/Media24si/ApiResource

Laravel 5 Guzzle Api Resource Package

  Sources   Download

MIT

The Requires

 

laravel guzzle laravel 5 rest client