Symfony 3.4.0 找不到要加载的任何夹具服务 [英] Symfony 3.4.0 Could not find any fixture services to load

查看:16
本文介绍了Symfony 3.4.0 找不到要加载的任何夹具服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Symfony 3.4.0,我尝试使用以下方式加载固定装置:

php bin/console 学说:fixtures:load

创建数据时出错,怎么回事?

解决方案

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

<块引用>

第一个:任何实现ORMFixtureInterface的类都会自动注册到这个标签中.

<块引用>

第二个:需要在sevice.yml配置中手动标记doctrine.fixture.ormDataFixtures.

服务:...# 使 src/AppBundle/DataFixtures 中的类可用作服务# 并且有一个标签允许操作来输入提示服务AppBundleDataFixtures:资源:'../../src/AppBundle/DataFixtures'标签: ['doctrine.fixture.orm']

I am using Symfony 3.4.0, I try to load fixtures with:

php bin/console doctrine:fixtures:load

An error occurred while creating the data, what's wrong?

解决方案

This command looks for all services tagged with doctrine.fixture.orm.
There is two ways to fix this problem.

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

<?php

namespace AppBundleDataFixturesORM;


use DoctrineBundleFixturesBundleORMFixtureInterface;
use DoctrineCommonPersistenceObjectManager;

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
    AppBundleDataFixtures:
        resource: '../../src/AppBundle/DataFixtures'
        tags: ['doctrine.fixture.orm']

这篇关于Symfony 3.4.0 找不到要加载的任何夹具服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆