使用带有Doctrine 2的灯具时出现致命错误

Ste*_*n S 7 php symfony doctrine-orm

我是Symblog 2初学者,我正在学习Symblog2的教程:http://tutorial.symblog.co.uk/docs/doctrine-2-the-blog-model.html .

我创建了我的数据模型,并尝试使用Doctrine 2 fixtures将测试数据填充到我的数据库中.

我下载了必要的软件包并将以下内容添加到我的autoload.php:

AppKernel.php

以下是php app/console doctrine:fixtures:load:

load()

我的fixtures类看起来像这样:

'Doctrine\\Common\\DataFixtures'    => __DIR__.'/../vendor/doctrine-fixtures/lib',
'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
Run Code Online (Sandbox Code Playgroud)

当我尝试运行时FixtureInterface::load,我得到以下异常:

new Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle(),
Run Code Online (Sandbox Code Playgroud)

我理解错误信息,但在我看来,我的autoload.php方法是兼容的AppKernel.php.

有人能告诉我,我错过了什么?我一步一步地按照教程.

Jak*_*las 10

v1.0.0-ALPHA2开始,FixtureInterface :: load()方法有一个类型提示:

use Doctrine\Common\Persistence\ObjectManager;

function load(ObjectManager $manager);
Run Code Online (Sandbox Code Playgroud)

  • 我还必须使用Doctrine\Common\Persistence\ObjectManager (2认同)

小智 8

您应该添加ObjectManager依赖项:

use Doctrine\Common\Persistence\ObjectManager;
Run Code Online (Sandbox Code Playgroud)