Skip to main content

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

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.