我已经生成了新的包:RusabTestBundle。它具有除其他事项外文件:为什么我不能在bundle的配置文件中使用配置?
- DependencyInjection
-- RusabTestBundleExtension.php
-- Configuration.php
在RusabTestBundleExtension.php我:
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
在的configuration.php我:
$rootNode = $treeBuilder->root('rusab_test_service');
下一页:
- Resources
-- services.yml
在services.yml中,我粘贴:
rusab_test_service:
而且我有错误:
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
但我我贴
rusab_test_service:
到
app/config/config.yml
那么这个好的工作。
为什么?我知道,我可以在app/config/config.yml中导入services.yml,但是在RusabTestBundleExtension.php中加载的是什么?
试试这个能力:https://stackoverflow.com/a/35505189和命名yml&Configuration.php文件中的关键字'rusab_test' –
@AlisterBulman它也不适用于我 – rusab
基本上,树构建器用于创建捆绑包默认配置。没有Bundle/resources/config.yml文件。然后当然可以使用app/config来覆盖特定的节点。 – Cerad