PHPackages                             smokills/laravel-http-client-default-options - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. smokills/laravel-http-client-default-options

AbandonedArchivedLibrary[HTTP &amp; Networking](/categories/http)

smokills/laravel-http-client-default-options
============================================

Extends the native Laravel Http Client, so that you can define global options

v2.0.2(4y ago)289.9k8MITPHPPHP &gt;=7.3

Since Oct 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/smokills/laravel-http-client-default-options)[ Packagist](https://packagist.org/packages/smokills/laravel-http-client-default-options)[ Docs](https://github.com/smokills/laravel-http-client-default-options)[ Fund](https://paypal.me/smokills)[ Fund](https://ko-fi.com/smokills)[ RSS](/packages/smokills-laravel-http-client-default-options/feed)WikiDiscussions stable Synced today

READMEChangelog (3)Dependencies (5)Versions (8)Used By (0)

[![Image of package](https://camo.githubusercontent.com/7bc31f02a2921c1d824313977bc405334b0dcd2b13fcc72fa2d968796ad22a45/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c25323048747470253230436c69656e7425323044656661756c742532304f7074696f6e732e6a7065673f7468656d653d6c69676874267061636b6167654e616d653d636f6d706f7365722b726571756972652b736d6f6b696c6c732532466c61726176656c2d687474702d636c69656e742d64656661756c742d6f7074696f6e73267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d457874656e64732b7468652b6e61746976652b4c61726176656c2b487474702b436c69656e742532432b736f2b746861742b796f752b63616e2b646566696e652b64656661756c742b6f7074696f6e73266d643d3126666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)](https://camo.githubusercontent.com/7bc31f02a2921c1d824313977bc405334b0dcd2b13fcc72fa2d968796ad22a45/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c25323048747470253230436c69656e7425323044656661756c742532304f7074696f6e732e6a7065673f7468656d653d6c69676874267061636b6167654e616d653d636f6d706f7365722b726571756972652b736d6f6b696c6c732532466c61726176656c2d687474702d636c69656e742d64656661756c742d6f7074696f6e73267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d457874656e64732b7468652b6e61746976652b4c61726176656c2b487474702b436c69656e742532432b736f2b746861742b796f752b63616e2b646566696e652b64656661756c742b6f7074696f6e73266d643d3126666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)

[![Latest Version on Packagist](https://camo.githubusercontent.com/cc3d950c2eac00fabe5090895b5bc69c91c34947163087b9929277567331e0f2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736d6f6b696c6c732f6c61726176656c2d687474702d636c69656e742d64656661756c742d6f7074696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smokills/laravel-http-client-default-options)[![Build Status](https://camo.githubusercontent.com/060294fc875d1c598e4ea96b8ce8aea9e1f0db6ef622d06efb50f95c3a56b80f/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f736d6f6b696c6c732f6c61726176656c2d687474702d636c69656e742d64656661756c742d6f7074696f6e732f737461626c652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.com/smokills/laravel-http-client-default-options?branch=stable)[![Total Downloads](https://camo.githubusercontent.com/4449ac90809daf32f86a25e4d056d04839554e38b859643d82cc6447431d0e9b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736d6f6b696c6c732f6c61726176656c2d687474702d636c69656e742d64656661756c742d6f7074696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smokills/laravel-http-client-default-options)[![License](https://camo.githubusercontent.com/87ddae9859ba29d94b0d2569e98042b73608a5af1b0fe1efc3ca421bd615b09b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f736d6f6b696c6c732f6c61726176656c2d687474702d636c69656e742d64656661756c742d6f7074696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smokills/laravel-http-client-default-options)

Set default available options to the Laravel Http Client.

Installation
------------

[](#installation)

Install the package via composer:

```
composer require smokills/laravel-http-client-default-options
```

### Laravel

[](#laravel)

In a Laravel environment, the package will be autoregistered thanks to the Laravel Package Auto-Discovery

### Lumen

[](#lumen)

If You would like use this package within a Lumen installation, you have to register the Service Provider in the `app/bootstrap.php`

```
$app->register(Smokills\Http\ServiceProvider::class);
```

Usage
-----

[](#usage)

You may define global options for the Http client in following way

```
// In a boot Service provider method (ex: the AppServiceProvider)

public function boot()
{
    ...

    Http::withDefaultOptions([
        'base_uri' => 'https://foo.com',
        'headers' => [
            'X-Bar-Header' => 'bar'
        ],
    ]);
}
```

From now on, all subsequent request will use the default options we have provided:

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

We can still continue add other options or helpers if we need:

```
// Somewhere in the code

/**
 * The debug option and the basic auth will be used together the default options defined before.
 */
$response = Http::withOptions([
    'debug' => 'true'
])->withBasicAuth('username', 'password')->get('/baz');
```

If you need to remove several or even all of the the default options, in order to make other requests, you may use the `withoutDefaultOptions` method.

```
// Remove all of the default options...
$response = Http::withoutDefaultOptions()->get('https://bar.com');

// Remove some of the global options
$response = Http::withoutDefaultOptions([
    'option', 'another-option'
])->get('https://bar.com');

// You can pass options to remove as arguments as well
$response = Http::withoutDefaultOptions('option', 'another-option')->get('https://bar.com');

// If you would like to remove deeply nested options, you may use the the dot notation syntax
$response = Http::withoutDefaultOptions('header.X-Some-Header')->get('https://bar.com');
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Vito Famiglietti](https://github.com/smokills)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~64 days

Recently: every ~73 days

Total

7

Last Release

1658d ago

Major Versions

v1.x-dev → v2.0.02021-10-25

PHP version history (4 changes)v1.0.0PHP ^7.3

v1.1.0PHP ^7.3 || ^8.0

v2.0.0PHP ^8.0

v2.0.1PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/b634fb933fc51c5193d9d51b827ee21f8e01d1e06bbe266fb939bb6825d09957?d=identicon)[smokills](/maintainers/smokills)

---

Top Contributors

[![smokills](https://avatars.githubusercontent.com/u/7535708?v=4)](https://github.com/smokills "smokills (24 commits)")

---

Tags

guzzlehacktoberfesthttplaravellaravel-packagelumenlumen-packagelaravelpackagesmokillslaravel-http-client-default-options

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/smokills-laravel-http-client-default-options/health.svg)

```
[![Health](https://phpackages.com/badges/smokills-laravel-http-client-default-options/health.svg)](https://phpackages.com/packages/smokills-laravel-http-client-default-options)
```

###  Alternatives

[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[onlime/laravel-http-client-global-logger

A global logger for the Laravel HTTP Client

1935.1k](/packages/onlime-laravel-http-client-global-logger)[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)[laragear/json

Easily retrieve and manipulate `Json` across your application.

363.5k](/packages/laragear-json)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
