Download the PHP package paulohps/laravel-db-config without Composer
On this page you can find all versions of the php package paulohps/laravel-db-config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-db-config
Laravel DB Config
Override Laravel config values at runtime with values stored in the database.
You decide, per config file, which keys may be overridden — either by allowing
only a few keys (only) or by allowing everything except a few keys (except).
The service provider reads the stored values on boot and applies the allowed
ones on top of the file-based configuration.
Requires PHP 8.4+ and Laravel 12+.
Installation
The migration for the db_config_settings table is loaded automatically.
Publishing the config file (and optionally the migration) is available via:
Configuration
Rules:
'*'allows every file. Files with an explicit entry keep their own rules even when'*'is present.only: only the listed keys of that file may be overridden.except: every key of that file may be overridden, except the listed ones — useful when excluding a few keys is shorter than listing all the others.- Keys match by dot-notation prefix:
fromalso coversfrom.address. - With
except, ancestors of an excluded key are blocked too (overridingfromcould smuggle a value into the excludedfrom.address), and whole-file overrides are never allowed when key rules exist. - When both
onlyandexceptare given for the same file,onlywins.
Usage
Stored keys are full config keys in dot notation (config file name first). Values that do not pass the rules above are ignored at apply time.
Values are JSON-encoded, so arrays, booleans, numbers and null round-trip.
Caching
With cache.enabled on (the default), the stored settings are cached — forever
when ttl is null, otherwise for ttl seconds — and the database is only
queried again after the cache is invalidated.
Every write that goes through the Eloquent model — set(), forget(), a
seeder or admin panel calling create()/update()/delete() on
DbConfigSetting — rebuilds the cache automatically. The observer handles
events after the transaction commits, so a rolled-back write never poisons the
cache. Writes that bypass model events (query-builder update(), DB::table(),
raw SQL) do not trigger the rebuild; after those, flush by hand:
On multi-server setups use a shared store (Redis, Memcached, database) so the
invalidation reaches every server; with a per-server store (file, array) the
other servers keep the stale payload until their ttl expires.
Caveats
config:cache: the overrides are applied at runtime on every request, on top of the (possibly cached) file config. With the settings cache disabled this costs one database query per request.- Boot order: providers that read config in
register(), or that boot before this package's provider, see the file value instead of the database value. - Resilience: when the database is unavailable or not migrated yet (fresh install, CI), the provider silently skips the overrides instead of taking the application down.
Laravel Boost
The package ships AI guidelines and a db-config-development agent skill for
Laravel Boost. In apps that use Boost, running
php artisan boost:install (or boost:update) picks both up automatically —
no publishing needed. The guideline gives coding agents always-on awareness
that config values may be overridden from the database; the skill carries the
detailed rules and pitfalls, loaded on demand.
Testing
License
MIT. See LICENSE.md.
All versions of laravel-db-config with dependencies
illuminate/contracts Version ^12.0
illuminate/database Version ^12.0
illuminate/support Version ^12.0