Reputation: 1405
I set up a bundle which defines some options via Configuration.php and the config three builder, which resides inside the bundle.
I want to put the configuration into the /root/app/config/config.yml file, but have the configuration be available inside the bundle via
$config = $container->getParameter('namespace');
So far, I can see the configuration being available via
bin/console debug:config namespace
but if I get the configuration inside the bundle code via
$config = $container->getParameter('namespace');
an exception gets thrown: "The parameter "namespace" must be defined" which it is, but the exception tells me otherwise.
My current Configuration.php:
class NamespaceExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
}
what am I missing here?
Upvotes: 0
Views: 65
Reputation: 5542
You misunderstood configuration and parameters. If you want access your configuration via parameters, you should set a parameter based on your configuration:
$container->setParameter('namespace', $config['namespace']);
Upvotes: 1