tomcizek / symfony-interop-container
Symfony Interop Container which has config array under 'config' key - for Extensions using Interoperability Factories.
Requires
- php: ^7.1
- psr/container: ^1.0
- sandrokeil/interop-config: ^2.1
- symfony/config: ^3.3
- symfony/dependency-injection: ^3.3
- symfony/expression-language: ^3.3
- symfony/framework-bundle: ^3.3
- symfony/http-kernel: ^3.3
- symfony/yaml: ^3.3
Requires (Dev)
- phpstan/phpstan: ^0.8.5
- phpunit/phpunit: ^6.2
This package is not auto-updated.
Last update: 2024-12-24 20:09:38 UTC
README
This bundle is handy when you want to create symfony vendor bundle that uses interoperability factories with interop config.
Why bother?
It registers 'interop_container' service for you, which has same services as default 'service_container', plus it returns app config array under key 'config'. This config is something you need to define in your extension.
Quick start
1) Install this library through composer
composer require tomcizek/symfony-interop-container
2) Register SymfonyInteropContainerBundle in your kernel
3) Create your Bundle with Extension and register in kernel too, for example:
class TestExtension extends AbstractInteropExtension { public function load(array $configs, ContainerBuilder $containerBuilder) { // parent call is mandatory, or it will not work as expected! parent::load($configs, $containerBuilder); // we can set another config key (default is extension alias: $this->getAlias()) $this->configBuilder->setKey('test'); // we can merge over another config $this->configBuilder->mergeOverByConfig([]); // we can merge over multiple configs $this->configBuilder->mergeOverByConfigs([[]]); // we can merge default config $this->configBuilder->mergeDefaultConfig([]); // if you want, you can build config by: $config = $this->configBuilder->build(); // it will be built in process method and injected into interop_container service } public function process(ContainerBuilder $containerBuilder) { // If you need to redefine process method, parent call is mandatory. parent::process($containerBuilder); } }
Contribute
Please feel free to fork and extend existing or add new features and send a pull request with your changes! To establish a consistent code quality, please provide unit tests for all your changes and may adapt the documentation.