Symfony2 DoctrineFixturesBundle namespace error

2019-05-16 18:08发布

I have a big problem with the fixtures bundle which I can't resolve. I follow the steps as they are meant to be followed, adding the lines to the deps file, installing them, registering them in the autoload and appkernel.

When I try to run even only app/console, it breaks with:

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

Which seems right because I don't have a DoctrineBundle directory under Doctrine\Bundle, only the DoctrineFixturesBundle. If I change that line to Symfony\Bundle\DoctrineBundle\... it works perfectly, because that class resides under that namespace actually.

Of course I can't leave it that way. I searched through the documentation, issues, everything, but it seems that noone has this same issue, so I must be missing some obvious point here.

Any ideas?

Thanks

1条回答
叛逆
2楼-- · 2019-05-16 18:51

Not long ago, all Doctrine bundles moved to the Doctrine organizaton. This causes some confusion based on which repository and branch you are using.

If you're using Symfony 2.0.x, then your deps should look something like this:

[DoctrineFixturesBundle]
    git=http://github.com/doctrine/DoctrineFixturesBundle.git
    target=bundles/Symfony/Bundle/DoctrineFixturesBundle
    version=origin/2.0

Notice the target/namespace is actually Symfony\Bundle\DoctrineFixturesBundle.


However, you shouldn't have any problems using the latest DoctrineFixturesBundle with Symfony 2.0.x - as long as you upgrade the rest of the Doctrine dependencies also. You can use this in your deps instead:

[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
查看更多
登录 后发表回答