rusab
rusab

Reputation: 3

Why I can't use configuration in config files of bundle?

I have generated new bundle: RusabTestBundle. It has among other things files:

- DependencyInjection
--  RusabTestBundleExtension.php
--  Configuration.php

In RusabTestBundleExtension.php I have:

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');

In Configuration.php I have:

$rootNode = $treeBuilder->root('rusab_test_service');

Next:

- Resources
-- services.yml

In services.yml I paste:

rusab_test_service:

And I have error:

There is no extension able to load the configuration for "rusab_test_service" (in /xxx/src/Rusab/TestBundle/DependencyInjection/../Resources/config/services.yml). Looked for namespace "rusab_test_service", found none

But I i paste

rusab_test_service:

to

app/config/config.yml

then this is working ok.

Why? I know, I can import services.yml in app/config/config.yml, but for what is loader in RusabTestBundleExtension.php?

Upvotes: 0

Views: 116

Answers (1)

Cerad
Cerad

Reputation: 48865

The way bundle configuration works is by building a configuration tree of all the various options.

You are trying to build the tree by loading in a config file which might be nice but it's not the way Symfony is designed.

So build your tree in Configuration.php and then give the application the ability to override specific values via app/config/config.yml

Upvotes: 0

Related Questions