安装JMSSerializerBundle

时间:2012-12-17 18:43:44

标签: symfony fosrestbundle symfony-2.0

我安装了FOSRestBundle但需要JMSSerializerBundle

我在我的代表中添加了下一行:

[JMSSerializerBundle]
    git=git://github.com/schmittjoh/JMSSerializerBundle.git
    target=bundles/JMS/SerializerBundle

这里解释了如何执行此操作:http://jmsyst.com/bundles/JMSSerializerBundle/master/installation

但是当我尝试$php bin/vendors install时,它会向我显示错误:

[InvalidArgumentException]                                          
  The service definition "jms_serializer.serializer" does not exist.  

3 个答案:

答案 0 :(得分:4)

您应该在new FOS\RestBundle\FOSRestBundle(),方法中对AppKernel.php中的registerBundles()行进行评论。然后安装JmsSerializerBundle,之后您应该推荐该行并注册JsmSerializerBundle

答案 1 :(得分:4)

手册说它用内核注册包:

new JMS\Serializer\JMSSerializerBundle($this),

但安装程序会创建文件夹:vendor/bundles/JMS/SerializerBundle

所以,必须将下一行添加到AppKernel.php而不是另一行:

new JMS\SerializerBundle\JMSSerializerBundle($this),

答案 2 :(得分:2)

您是否也从手册中执行了以下步骤?听起来像你没有添加行

new JMS\Serializer\JMSSerializerBundle($this)

到AppKernel.php