Symfony 3.4.0找不到要加载的任何夹具服务

我正在使用Symfony 3.4.0,我尝试使用以下命令加载灯具:

php bin/console doctrine:fixtures:load

创建数据时出错,出了什么问题?

enter image description here

此命令查找使用doctrine.fixture.orm标记的所有服务.
有两种方法可以解决这个问题.

First one: any class that implements ORMFixtureInterface will automatically be registered with this tag.

<?php

namespace AppBundle\DataFixtures\ORM;


use Doctrine\Bundle\FixturesBundle\ORMFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;

class LoadFixtures implements ORMFixtureInterface
{
    public function load(ObjectManager $manager)
    {
        #your code
    }
}

Second one: You need manually tag doctrine.fixture.orm to DataFixtures in sevice.yml configuration.

services:
    ...

    # makes classes in src/AppBundle/DataFixtures available to be used as services
    # and have a tag that allows actions to type-hint services
    AppBundle\DataFixtures\:
        resource: '../../src/AppBundle/DataFixtures'
        tags: ['doctrine.fixture.orm']
https://stackoverflow.com/questions/47613979/symfony-3-4-0-could-not-find-any-fixture-services-to-load

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:Symfony 3.4.0找不到要加载的任何夹具服务