bartlomiejbeta / di-env-loader-bundle
Installs: 654
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.0
- symfony/symfony: ^3.0|^3.2
Requires (Dev)
- phpunit/phpunit: ^5.4|^6.0
- symfony/phpunit-bridge: ~2.7
This package is auto-updated.
Last update: 2024-11-17 10:27:26 UTC
README
Easily load kernel environment dependent config files.
instalation
composer require bartlomiejbeta/di-env-loader-bundle
usage
simple
class ExampleExtension extends Extension { use DIEnvLoaderTrait; public function load(array $configs, ContainerBuilder $container) { $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); self::loadByEnv($loader, $container, 'services', 'yml'); } }
configs will be load for all kernel environments.
- for example for
test
environment fileservices-test.yml
located inResources/config
(and so on for other environment)
configured
class ExampleExtension extends Extension { use DIEnvLoaderTrait; public function load(array $configs, ContainerBuilder $container) { $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config/test')); if ('test' === self::getEnv($container)) { self::loadByEnv($loader, $container, 'services', 'yml', '.'); } } }
configs will be load only for test
kernel environment.
- file
services.test.yml
located inResources/config/test