---
title: "Config bridge — Options for Laravel | Roundly"
description: "Let stored options override Laravel config() values at boot — change mail senders or the app name from the database."
url: https://roundly-consulting.com/open-source/docs/options-for-laravel/config-bridge
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Options for Laravel](https://roundly-consulting.com/open-source/docs/options-for-laravel.md)

# Config bridge

Map config() keys to options, and their stored values override config at boot — change a mail sender or the app name from the database, without editing .env or redeploying:

```php
// config/options.php
'config_overrides' => [
    'mail.from.address' => App\Options\MailFromAddressOption::class,
    'app.name'          => App\Options\AppNameOption::class,
],
```

```php
Options::set(MailFromAddressOption::class, 'hello@example.com');
// config('mail.from.address') === 'hello@example.com' after the next boot

// Register a mapping at runtime (applied immediately):
Options::overrides('app.name', AppNameOption::class);
Options::configOverrides();      // the active map
Options::applyConfigOverrides(); // re-read every mapped option into config() now
```

- Only the global scope is applied.
- A mapped option with no stored value leaves the existing config value alone, so framework and .env defaults are never clobbered.
- Mappings accept class-strings or registered keys. An unknown class or key in config\_overrides throws InvalidOptionClassName at boot.
- The bridge reads its options without access control, so an option guarded by authorizeRead() still reaches config.
- At boot each mapping costs one existence check, plus a cached read when a value is stored. Errors while applying — for example, the options table not existing yet on a fresh install — are swallowed, so the app still boots.

## Live mode

With options.config\_overrides\_live enabled, set() and forget() on a mapped option re-apply the config key in the current process; forget() reverts it to the value config had before the bridge touched it. The write calls the bridge itself, so live mode works with events off too; inside a transaction the re-apply waits for the commit, and a rolled-back write leaves config() alone:

```bash
OPTIONS_CONFIG_OVERRIDES_LIVE=true
```

## Boot-order caveat

Only code that reads a mapped config key after the package boots sees the override. Config consumed earlier in the bootstrap — or read from a config:cache’d file before providers boot — is unaffected.

The bridge doesn’t apply while config:cache (or optimize, which runs it) builds that file, so no stored value — and no decrypted encrypted value — is baked into bootstrap/cache/config.php. The file keeps the file and env values, every boot applies the stored ones on top, and forget() brings the file value back.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/options-for-laravel.md)
