laravel-dynamic-config maintained by pharaonic
Description
Store Laravel configuration values in the database, globally, per identifier or per model, and load them into the config repository with Config::dynamic()->load().
Author
Last update
2026/11/04 08:38
(dev-develop)
License
Downloads
2
Tags
Installation
composer require pharaonic/laravel-dynamic-config
php artisan migrate
The service provider is registered automatically. Publish the configuration when you need to change it:
php artisan vendor:publish --tag=dynamic-config-config
Usage
use Illuminate\Support\Facades\Config;
// Persist values: the global scope, one identifier, or one saved model.
Config::dynamic()->set('mail.from.address', 'global@example.com');
Config::dynamic('branch-12')->set('mail.from.address', 'branch@example.com');
Config::dynamic($company)->set('app.timezone', 'Africa/Cairo');
// Apply them, in the order you want them to win.
Config::dynamic()->load();
Config::dynamic('branch-12')->load();
// Read the final value with Laravel itself.
config('mail.from.address'); // branch@example.com
A model scope is stored under the identifier {morph class}:{key}. Each load() merges one scope only, and nothing is loaded automatically. get(), has(), all() and forget() work on the values stored in that one scope; config() returns the resolved runtime value.
Every scope is cached until it is written. Loaded values live only in memory, on top of Laravel's config cache. Long-running processes such as queue workers keep them between jobs, so load each scope where its requests or jobs start.
Documentation
Full documentation: Laravel Dynamic Config Documentation.
Support & Security
See SUPPORT.md and SECURITY.md. Contributions are welcome; see CONTRIBUTING.md.
License
MIT. See LICENSE.