Extends the native Laravel Http Client, so that you can define global options https://github.com/smokills/laravel-http-client-default-options
// install
composer require smokills/laravel-http-client-default-options
// In a boot Service provider method (ex: the AppServiceProvider)
public function boot()
{
...
Http::withDefaultOptions([
'base_uri' => 'https://foo.com',
'headers' => [
'X-Bar-Header' => 'bar'
],
]);
}
// Somewhere in the code
/**
* Since we have defined the base_uri as default option, we can simply make a
* request using only the uri.
*/
$response = Http::get('/baz');