Load .env configuration files for your Gacela projects.
composer require gacela-project/gacela-env-config-readerYou can define the reader configuration either in the Gacela::bootstrap() or in a gacela.php file.
Define the configuration in a gacela.php file in the root of your project (recommended way):
<?php # gacela.php
use Gacela\Framework\Bootstrap\GacelaConfig;
use Gacela\Framework\Config\ConfigReader\EnvConfigReader;
return static function (GacelaConfig $config): void {
$config->addAppConfig('config/.env*', 'config/.env.local.dist', EnvConfigReader::class);
};Define all configuration on the fly in the bootstrap itself.
<?php # public/index.php
use Gacela\Framework\Bootstrap\GacelaConfig;
use Gacela\Framework\Config\ConfigReader\EnvConfigReader;
use Gacela\Framework\Gacela;
$config = static function (GacelaConfig $config): void {
$config->addAppConfig('config/.env*', 'config/.env.local.dist', EnvConfigReader::class);
};
Gacela::bootstrap($appRootDir, $config);$config = static function (GacelaConfig $config): void {
$config->addAppConfig('config/.env*', 'config/.env.local.dist', EnvConfigReader::class);
$config->addAppConfig('config/*.php', 'config/local.php');
$config->addAppConfig('config/*.custom', '', CustomConfigReader::class);
}