Extending
The config is designed to be extended.
You can add your own config files to the config directory, write providers that act on them, and replace built-in providers when you need different behaviour.
Adding a new config file
Section titled “Adding a new config file”Create a new file in the config directory. Any PHP file there is automatically loaded — the filename (without .php) becomes the top-level config key.
<?php
return [ 'foo' => 'bar',];Read it anywhere with Config::get():
Config::getInstance()->get('foobar.foo'); // 'bar'Adding a provider
Section titled “Adding a provider”A provider is a class responsible for reading config values and acting on them when the theme boots. Every built-in config file has a corresponding provider in app/Lib/Config/Provider/.
To add your own, create a class that implements ProviderContract:
<?php
namespace App\Provider;
use App\Lib\Config\Config;use App\Lib\Contracts\ProviderContract;
class FoobarProvider implements ProviderContract{ public function boot(): void { $value = Config::getInstance()->get('foobar.foo');
if ($value === 'bar') { // do something } }}Register it in functions.php before calling $config->load():
$config = Config::getInstance();
$config->addProvider(new App\Provider\FoobarProvider);
$config->load();Replacing an existing provider
Section titled “Replacing an existing provider”If you need to change how a built-in config file is handled, extend the existing provider and swap it out with replaceProvider().
<?php
namespace App\Provider;
use App\Lib\Config\Provider\ThemeProvider;
class MyThemeProvider extends ThemeProvider{ public function boot(): void { parent::boot();
// run additional logic after the default theme setup }}$config = Config::getInstance();
$config->replaceProvider(ThemeProvider::class, new App\Provider\MyThemeProvider);
$config->load();replaceProvider finds the first registered provider that is an instance of the given class and swaps it. If no match is found, the replacement is appended instead.
To completely override a provider without running the original logic, omit the parent::boot() call.

