amkr / laravel-guzzle-provider
Support classes to provide Guzzle in Laravel 5
Installs: 12 706
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- guzzlehttp/guzzle: ^6.0
- illuminate/support: ^5.0
This package is not auto-updated.
Last update: 2024-11-23 21:04:20 UTC
README
This is a simple Laravel Service Provider and Facade to access GuzzleHttp/Client, using configuration from a config file.
Installation
To install the PHP client library using Composer:
composer require amkr/laravel-guzzle-provider
Then add Amkr\Laravel\Guzzle\Providers\GuzzleServiceProvider
to the providers array in your config/app.php
.
Amkr\Laravel\Guzzle\Providers\GuzzleServiceProvider::class,
Add the Facade to the alias array in your app/config.php
:
'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:
php artisan vendor:publish
Adjust your configuration in config/guzzle.php
:
'default' => [
'base_uri' => 'http://localhost',
'verify' => '/path/to/ca-chain.pem',
],
Usage
You can access GuzzleHttp\Client through the Guzzle facade:
Guzzle::post('url', []);
Or you can specify to use a non-default configuration name by using the client()
method:
Guzzle::client('my-config')->post('url', []);