I have a command in Symfony2 and I want to be able to read the devel config from config_dev.yml
I'm trying to retrieve the config in the command execute
method like this:
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->getContainer()->getParameter('parse');
}
But when I execute the command:
$ php app/console acme:test
It gives me the following error message:
There is no extension able to load the configuration for "acme"
Data in config_dev.yml
that I want to retrieve:
acme:
foo: "bar"
The command extends containerAwareCommand
:
class AcmeCommand extends containerAwareCommand
Any suggestions how to achieve this?
Update
Configuration tree example:
// src/Acme/ApiBundle/DependencyInjection/Configuration.php
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('acme');
$rootNode
->children()
->scalarNode('foo')->end()
->end()
;
return $treeBuilder;
}
Extension example:
// src/Acme/ApiBundle/DependencyInjection/AcmeApiExtension.php
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$container->setParameter('acme', $config);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
config_dev.yml example:
...
acme:
foo: "bar"