Configuration
A project converted by osdd:start has no root config/ folder. Each layer brings the config it needs, and overrides the config of other packages, through its provider. The settings of OSDD itself are in the configuration reference.
Give a layer its own config file
php artisan osdd:config orders --layer=functional/orders
The command creates functional/orders/config/orders.php and adds this line to the register() method of the layer provider:
$this->overrideConfigFrom(__DIR__ . '/../../config/orders.php', 'orders');
Read it as usual: config('orders.reminder_days').
Override another package's config
Laravel's mergeConfigFrom() keeps the values that are already loaded: a package uses it to fill in its defaults. overrideConfigFrom() does the opposite: the layer's values win, like a file in the application's config/ folder.
public function register(): void
{
$this->overrideConfigFrom(__DIR__ . '/../../config/horizon.php', 'horizon');
}
return [
'path' => 'admin/horizon',
'middleware' => ['web', 'auth'],
];
| Method | Who wins | Runs |
|---|---|---|
mergeConfigFrom() | The values already loaded | In register() |
overrideConfigFrom() | The layer's values | In register(), skipped when the config is cached |
overrideConfigFrom() from register(), not boot(). Packages read their config while they boot: Horizon reads horizon.path and horizon.middleware to register its routes. An override applied in boot() may come too late.Maps and lists
Maps are merged key by key, at every depth: nested keys you leave out keep their value. A list replaces the loaded list as a whole, and an empty array clears the loaded value:
// loaded: ['queues' => ['default', 'low'], 'timeout' => 60]
// layer file: ['queues' => ['high']]
// result: ['queues' => ['high'], 'timeout' => 60]
Write the full list in the layer file when you want to keep some of the loaded items.
Cached configuration
php artisan config:cache stores the merged result. overrideConfigFrom() does nothing once the config is cached, so run config:cache again after changing a layer's config file.