Guzzle Package for Laravel 5
This is a simple Laravel Service Provider and Facade to access GuzzleHttp/Client, using configuration from a config file., (*1)
Installation
To install the PHP client library using Composer:, (*2)
composer require amkr/laravel-guzzle-provider
Then add Amkr\Laravel\Guzzle\Providers\GuzzleServiceProvider
to the providers array in your config/app.php
., (*3)
Amkr\Laravel\Guzzle\Providers\GuzzleServiceProvider::class,
Add the Facade to the alias array in your app/config.php
:, (*4)
'Guzzle' => Amkr\Laravel\Guzzle\Facades\Guzzle::class,
Configuration
You can use artisan vendor:publish
to copy the distribution configuration file to your app's config directory:, (*5)
php artisan vendor:publish
Adjust your configuration in config/guzzle.php
:, (*6)
'default' => [
'base_uri' => 'http://localhost',
'verify' => '/path/to/ca-chain.pem',
],
Usage
You can access GuzzleHttp\Client through the Guzzle facade:, (*7)
Guzzle::post('url', []);
Or you can specify to use a non-default configuration name by using the client()
method:, (*8)
Guzzle::client('my-config')->post('url', []);