使用Symfony2安装DoctrineFixturesBundle

时间:2012-08-28 14:42:59

标签: symfony

我尝试安装现有的Symfony 2.0项目,因此我运行rm -rf vendor和bin / vendor install。 他找不到DoctrineFixturesBundle,所以我更新了我的deps文件,然后我把:

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

我再次运行rm -rf vendor / *和bin / vendor install,我收到此错误:

自动加载器预期类“Symfony \ Bundle \ DoctrineFixturesBundle \ DoctrineFixturesBundle”将在文件“/home/me/developpement/myproject/app/../vendor/bundles/Symfony/Bundle/DoctrineFixturesBundle/DoctrineFixturesBundle中定义.PHP”。找到该文件但该类不在其中,类名或命名空间可能有拼写错误。

所以,在我的AppKernel.php中,我替换:

new Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle(),

with:

new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),

因为DoctrineFixturesBundle.php文件命名空间是Doctrine \ Bundle \ FixturesBundle。

现在,我收到了这个错误:

致命错误:第21行的/home/me/developpement/myproject/app/AppKernel.php中找不到类'Doctrine \ Bundle \ FixturesBundle \ DoctrineFixturesBundle'

我该怎么做才能让它发挥作用?

已编辑添加

这是我的autoload.php:

$loader->registerNamespaces(array(
    'Symfony'          => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
    'Sensio'           => __DIR__.'/../vendor/bundles',
    'JMS'              => __DIR__.'/../vendor/bundles',
    'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
    'Doctrine\\DBAL'   => __DIR__.'/../vendor/doctrine-dbal/lib',
    'Doctrine'         => __DIR__.'/../vendor/doctrine/lib',
    'Monolog'          => __DIR__.'/../vendor/monolog/src',
    'Assetic'          => __DIR__.'/../vendor/assetic/src',
    'Metadata'         => __DIR__.'/../vendor/metadata/src',
    'Gedmo'            => __DIR__.'/../vendor/gedmo-doctrine-extensions/lib',
    'Doctrine\\Common\\DataFixtures' => __DIR__.'/../vendor/doctrine-fixtures/lib',
    'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
    'Doctrine\\DBAL\\Migrations' => __DIR__.'/../vendor/doctrine-migrations/lib',
    'Doctrine\\DBAL'   => __DIR__.'/../vendor/doctrine-dbal/lib',
    'Knp\Component'    => __DIR__.'/../vendor/knp-components/src',
    'Knp\Bundle'       => __DIR__.'/../vendor/bundles',
 ));

2 个答案:

答案 0 :(得分:2)

你检查过autoload.php了吗?这是您告诉Symfony哪个Namespace位于特定目录中的地方。

答案 1 :(得分:0)

命名空间可能未自动加载。检查此vendor\composer\autoload_namespaces.php文件,确保其中包含以下代码。

'Doctrine\\Bundle\\FixturesBundle' => array($vendorDir . '/doctrine/doctrine-fixtures-bundle')