bitstone/guzzle-wrapper

This package is abandoned and no longer maintained. The author suggests using the Laravel 7.0 implemented its own HttpClient package instead.

A laravel wrapper around the Guzzle Client API.

v1.8 2019-09-20 13:02 UTC

This package is auto-updated.

Last update: 2020-05-26 15:02:10 UTC


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');