Symfony2 DoctrineFixturesBundle命名空间错误

sta*_*mas 3 php doctrine fixtures symfony

我遇到了一个我无法解决的固定装置捆绑的大问题.我按照要执行的步骤进行操作,将行添加到deps文件,安装它们,在autoload和appkernel中注册它们.

当我尝试只运行时app/console,它打破了:

Fatal error: Class 'Doctrine\Bundle\DoctrineBundle\Command\DoctrineCommand' not found in /var/www/.../bundles/Doctrine/Bundle/FixturesBundle/ Command/LoadDataFixturesDoctrineCommand.php on line 40

这似乎是正确的,因为我没有DoctrineBundle目录Doctrine\Bundle,只有DoctrineFixturesBundle.如果我将该行更改为Symfony\Bundle\DoctrineBundle\...完美的工作,因为该类实际上位于该命名空间下.

当然我不能这样离开.我搜索了文档,问题,一切,但似乎没有人有同样的问题,所以我必须在这里忽略一些明显的观点.

有任何想法吗?

谢谢

lee*_*eek 5

不久前,所有Doctrine捆绑都转移到了Doctrine组织.这会根据您使用的存储库和分支导致一些混淆.

如果您使用的是Symfony 2.0.x,那么您deps应该看起来像这样:

[DoctrineFixturesBundle]
    git=http://github.com/doctrine/DoctrineFixturesBundle.git
    target=bundles/Symfony/Bundle/DoctrineFixturesBundle
    version=origin/2.0
Run Code Online (Sandbox Code Playgroud)

请注意目标/命名空间实际上是Symfony\Bundle\DoctrineFixturesBundle.


但是,使用DoctrineFixturesBundleSymfony 2.0.x 的最新版本不应该有任何问题- 只要您升级其余的Doctrine依赖项.你可以在你的使用中使用它deps:

[doctrine-common]
    git=http://github.com/doctrine/common.git
    version=2.2.0

[doctrine-dbal]
    git=http://github.com/doctrine/dbal.git
    version=2.2.1

[doctrine]
    git=http://github.com/doctrine/doctrine2.git
    version=2.2.0

[doctrine-fixtures]
    git=http://github.com/doctrine/data-fixtures.git

[DoctrineFixturesBundle]
    git=http://github.com/doctrine/DoctrineFixturesBundle.git
    target=bundles/Doctrine/Bundle/FixturesBundle
Run Code Online (Sandbox Code Playgroud)

  • 非常感谢您的评论.最后我设法让它运作起来.我使用了旧的deps代码用于FixturesBundle,并将其定位到Symfony\Bundle而不是Doctrine\Bundle.我对此失去了理智.我不知道当2.1出来时会发生什么,哈哈.再次感谢你. (2认同)