我试图安装一个现有的Symfony 2.0项目,因此我运行rm -rf供应商和bin/供应商安装。他找不到DoctrineFixturesBundle,所以我更新了我的deps文件,我写了:
[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中,我替换了:
new Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle(),有:
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),因为DoctrineFixturesBundle.php文件命名空间是Doctrine\Bundle\FixturesBundle。
现在,我得到了一个错误:
'Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle‘致命错误:在第21行的/home/me/developpement/myproject/app/AppKernel.php中找不到类
我该怎么做才能让它发挥作用?
编辑以添加
这是我的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',
));发布于 2012-08-28 15:26:39
你检查你的autoload.php了吗?这是您告诉Symfony哪个Namespace位于特定目录中的地方。
发布于 2014-02-06 09:36:44
命名空间可能不是自动加载的。检查这个vendor\composer\autoload_namespaces.php文件并确保它包含以下代码。
'Doctrine\\Bundle\\FixturesBundle' => array($vendorDir . '/doctrine/doctrine-fixtures-bundle'),
https://stackoverflow.com/questions/12161809
复制相似问题