
[英]Composer conflicts when installing orm-fixtures in Symfony 4/5
[英]Fixture - orm-fixtures - Symfony - Undefined type message
我已经成功安装 Symfony 6 并且我正在尝试使用夹具在我的数据库中包含随机数据。 我按照本教程https://symfony.com/bundles/DoctrineFixturesBundle/current/index.html
但是使用命令后
composer require --dev orm-fixtures
并复制/过去:
// src/DataFixtures/AppFixtures.php
namespace App\DataFixtures;
use App\Entity\Product;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
class AppFixtures extends Fixture
{
public function load(ObjectManager $manager)
{
// create 20 products! Bam!
for ($i = 0; $i < 20; $i++) {
$product = new Product();
$product->setName('product '.$i);
$product->setPrice(mt_rand(10, 100));
$manager->persist($product);
}
$manager->flush();
}
}
为什么我会收到此消息:
Undefined type 'Doctrine\Bundle\FixturesBundle\Fixture'.intelephense(1009)
在从线的夹具下:
class AppFixtures extends Fixture
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.