我正在尝试使用 JMSSerializerBundle,我使用 Composer 安装了它。
我用 symfony 生成器生成了我的 OwnBundle,我可以使用 $this->get('serializer')
但是,我想覆盖文档中所述的配置,所以我在 My/OwnBundle/Resources/config/
中创建了一个 config.yml 并放置了
jms_serializer:
metadata:
directories:
OwnBundle:
namespace_prefix: My\OwnBundle
path: %kernel.root_dir%/serializer/
为了确保我的配置已加载,我添加了
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
$loader->load('config.yml');
但是我在运行控制台工具时遇到了这个错误:
There is no extension able to load the configuration for "jms_serializer" (in ~/My/OwnBundle/DependencyInjection/../Resources/config/config.yml). Looked for namespace "jms_serializer", found none
我做错了什么吗?
有关信息,我的 services.yml 是空的(空服务和参数)。
我是 Symfony2 的新手,但我是 RTFM。
最佳答案
您是否忘记在 autoload.php 中注册 JMSSerializer 命名空间?检查该文件以查看它是否存在。
关于symfony - 如何覆盖供应商捆绑配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9627461/