我无法找到一种方法来security.yml
包含根据 Symfony2 的环境而包含的不同文件。例如,我想为我的验收测试提供一个内存用户提供程序,因为我真的不需要在这里测试我的实体和东西,我只想对我的视图进行验收测试。
但是,事实证明,这并不是一件容易的事。我security.yml
从我的包含中删除config.yml
,将其重命名为security_prod.yml
并创建了一个security_test.yml
包含in_memory
用户提供程序的内容。然后我分别在我的生产和测试配置中包含security_prod.yml
和。security_test.yml
然而它似乎根本不起作用:
$ SYMFONY_ENV=test app/console cache:clear
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
You are not allowed to define new elements for path "security.providers". Please define all elements for this path in one config file.
$ SYMFONY_ENV=prod app/console cache:clear
[Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException]
Configuration path "security.access_control" cannot be overwritten. You have to define all options for this path, and any of its sub-paths in one
configuration section.
在我看来,security.yml
文件名是硬编码的(这对 Symfony 来说太奇怪了),但事实并非如此。
所以问题是:如何security.yml
使用 Symfony 获得多个 s?什么可能导致这种行为?