gacela-project / gacela-yaml-config-reader
Load yaml/yml files into Gacela
dev-main
2023-05-14 11:22 UTC
Requires
- php: ^8.0, <8.3
- gacela-project/gacela: *
- symfony/yaml: ^5.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.13
- infection/infection: ^0.26
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.18
- symfony/var-dumper: ^5.4
- vimeo/psalm: ^5.1
This package is auto-updated.
Last update: 2024-10-14 14:40:32 UTC
README
Load yaml/yml configuration files for your Gacela projects.
composer require gacela-project/gacela-yaml-config-reader
Setup
You can define the reader configuration either in the Gacela::bootstrap()
or in a gacela.php
file.
Option A)
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\YamlConfigReader; return static function (GacelaConfig $config): void { $config->addAppConfig('config/*.{yaml,yml}', 'config/local.yaml', YamlConfigReader::class); };
Option B)
Define all configuration on the fly in the bootstrap itself.
<?php # public/index.php use Gacela\Framework\Bootstrap\GacelaConfig; use Gacela\Framework\Config\ConfigReader\YamlConfigReader; use Gacela\Framework\Gacela; $config = static function (GacelaConfig $config): void { $config->addAppConfig('config/*.{yaml,yml}', 'config/local.yaml', YamlConfigReader::class); }; Gacela::bootstrap($appRootDir, $config);
You can define more than one ConfigReader
at once.
$config = static function (GacelaConfig $config): void { $config->addAppConfig('config/*.{yaml,yml}', 'config/local.yaml', YamlConfigReader::class); $config->addAppConfig('config/*.php', 'config/local.php'); $config->addAppConfig('config/*.custom', '', CustomConfigReader::class); }