gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 11:46:38 28 4
gpt4 key购买 nike

我正在使用 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']

关于Symfony 3.4.0 找不到任何要加载的 fixture 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47613979/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com