Search by

pharaonic / laravel-dynamic-config

Pharaonic

Store Laravel configuration values in the database, globally, per identifier or per model, and load them into the config repository with Config::dynamic()->load().

Package info

github.com/Pharaonic/laravel-dynamic-config

Documentation

pkg:composer/pharaonic/laravel-dynamic-config

Fund package maintenance!

MoamenEltouny

Buy Me A Coffee

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

13.0.0 2026-11-04 05:22 UTC

This package is auto-updated.

Last update: 2026-11-04 05:35:50 UTC


README

PHP Version : 8.3, 8.4, 8.5 Laravel Version : 13.x License Build
Source Packagist Version Packagist Downloads

Store Laravel configuration values in the database, globally, per identifier or per model, and load them into config() when you choose.


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.