Configuration System
Beauty Framework uses a clean and consistent configuration system based on plain PHP arrays. All configuration files live in the config/
directory and are automatically loaded at runtime.
You can access configuration values via the global config()
helper:
config('cache.default'); // 'redis'
config('database.connections.pgsql.host'); // '127.0.0.1'
You can also inject the ConfigRepository
class if needed.
use Beauty\Core\Config\ConfigRepository;
public function __construct(
private ConfigRepository $config
) {
$defaultCache = $this->config->get('cache.default');
}
π Directory Structureβ
All configuration files live in the config/
directory. For example:
config/
βββ app.php
βββ cache.php
βββ database.php
βββ events.php
βββ jobs.php
βββ logging.php
βββ queue.php
βββ services.php
π§© Nested Keysβ
You can use dot notation to access deeply nested values:
config('database.connections.pgsql.port'); // 5432
π Cachingβ
Internally, the configuration system caches parsed configs for fast access. You donβt need to manually warm up anything.
π§± Extensibilityβ
You can easily add your own configuration files in config/
.
Example: config/image.php
<?php
return [
'resize' => true,
'max_width' => 1920,
];
Access:
config('image.max_width'); // 1920
π Configuration Loaderβ
The internal loader is responsible for recursively loading all files in config/
. It also supports environment overrides and ensures immutability after boot (unless explicitly allowed).
π Where It's Definedβ
The main configuration loader is registered in:
App\Container\Config\RegisterConfig
π Related Docsβ
Use those docs if you want to create your own config or provide providers for new services.
Beauty makes config access and customization seamless and developer-friendly β no more .env
hunting or YAML chaos.