laravel guzzle service provider
composer require kozz/laravel-guzzle-provider ~5.0
Or manualy in composer.json:
"require": {
"kozz/laravel-guzzle-provider": "~5.0"
}
composer require kozz/laravel-guzzle-provider ~6.0
Or manualy in composer.json:
"require": {
"kozz/laravel-guzzle-provider": "~6.0"
}
This package supports auto discovery, so no configuration is required.
/configs/app.php
...
'providers' => [
/*
* Laravel Framework Service Providers...
*/
...
/*
* Application Service Providers...
*/
...
'Kozz\Laravel\Providers\Guzzle'
],
/configs/app.php
...
'aliases' => [
...
'Guzzle' => 'Kozz\Laravel\Facades\Guzzle'
],
$response = \Guzzle::get('https://google.com');
$client = app()->offsetGet('guzzle');
$client = \Illuminate\Container\Container::getInstance()->offsetGet('guzzle');
$client = \Kozz\Laravel\Facades\Guzzle::getFacadeRoot();
$client = \Guzzle::getFacadeRoot();
$response = Guzzle::post(
'https://httpbin.org/post',
[
'form_params' => [
'id' => 222
]
]
);
$response = Guzzle::post(
'https://httpbin.org/post',
[
'auth' => [ 'theUsername', 'thePassword'],
]
);
generates:
+"Authorization": "Basic dGhlVXNlcm5hbWU6dGhlUGFzc3dvcmQ="