bitstone / guzzle-wrapper
A laravel wrapper around the Guzzle Client API.
Installs: 4 655
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^7.0
- guzzlehttp/guzzle: ~6.0
- illuminate/support: ~5.4
Requires (Dev)
- mockery/mockery: 0.9
- phpunit/phpunit: 6.*
README
A simple wrapper for guzzle http requests, to make the http calls using headers easier
Install
Install this package using composer
composer require bitstone/guzzle-wrapper or add the library to your composer.json file: "bitstone/guzzle-wrapper": "^1.6"
Then you need to update the service providers array, in your config/app.php
Bitstone\GuzzleWrapper\HttpServiceProvider::class
And the alias for the facade
'Http' => Bitstone\GuzzleWrapper\Http::class
Usage
Http::request('GET', http://example.com/api/v1/users', ['role' => 'admin'], ['Content-Type' => 'application/json']);
Or
Http::request('GET', http://example.com/api/v1/users?role=admin', [], ['Content-Type' => 'application/json']);
Http::request('POST', http://example.com/api/v1/users', ['option' => 'value'], ['Content-Type' => 'application/json', 'Accept' => 'application/json']);
But it's possible to call the specific http method as well:
Http::get('http://example.com/api/v1/users');
Http::post('http://example.com/api/v1/users/1', ['option' => 'value'], ['Accept' => 'application/json']);
Http::put('http://example.com/api/v1/users/1', ['option' => 'another value'], ['Accept' => 'application/json']);
Http::delete('http://example.com/api/v1/users/1');
Http::head('http://example.com/api/v1/users/1');