首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用DoctrineFixturesBundle安装Symfony2

用DoctrineFixturesBundle安装Symfony2
EN

Stack Overflow用户
提问于 2012-08-28 14:42:58
回答 2查看 3.2K关注 0票数 4

我试图安装一个现有的Symfony 2.0项目,因此我运行rm -rf供应商和bin/供应商安装。他找不到DoctrineFixturesBundle,所以我更新了我的deps文件,我写了:

代码语言:javascript
复制
[DoctrineFixturesBundle]
    git=https://github.com/doctrine/DoctrineFixturesBundle.git
    target=/bundles/Symfony/Bundle/DoctrineFixturesBundle
    version=origin/2.0

我再次运行rm -rf供应商/*和bin/安装,并得到以下错误:

自动加载器期望在文件"Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle“中定义的类"/home/me/developpement/myproject/app/../vendor/bundles/Symfony/Bundle/DoctrineFixturesBundle/DoctrineFixturesBundle.php".找到了该文件,但类不在其中,类名或命名空间可能有一个错误.。

因此,在我的AppKernel.php中,我替换了:

代码语言:javascript
复制
new Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle(),

有:

代码语言:javascript
复制
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),

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

现在,我得到了一个错误:

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

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

编辑以添加

这是我的autoload.php:

代码语言:javascript
复制
$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',
 ));
EN

回答 2

Stack Overflow用户

发布于 2012-08-28 15:26:39

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

票数 2
EN

Stack Overflow用户

发布于 2014-02-06 09:36:44

命名空间可能不是自动加载的。检查这个vendor\composer\autoload_namespaces.php文件并确保它包含以下代码。

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12161809

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档