Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

symfony4.1.3 The import Doctrine\Bundle\FixturesBundle\Fixture cannot be resolved

Tags:

symfony4

I am learning Symfony 4.1.3.

I have created my demo project with composer:

composer -V: Composer version 1.7.1 2018-08-07 09:39:23

I have installed orm-fixtures:

composer require orm-fixture
    Using version ^3.0 for doctrine/doctrine-fixtures-bundle
    ./composer.json has been updated
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Restricting packages listed in "symfony/symfony" to "4.1.*"
    Nothing to install or update
    Generating autoload files
    ocramius/package-versions:  Generating version class...
    ocramius/package-versions: ...done generating version class

I have then created my fixture:

php bin/console make:fixtures

A file src/DataFixtures/ArticleFixtures.php has been created:

<?php
namespace App\DataFixtures;

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

class ArticleFixtures extends Fixture
{

    public function load(ObjectManager $manager)
    {
        // $product = new Product();
        // $manager->persist($product);
        $manager->flush();
    }
}

And then the line use Doctrine\Bundle\FixturesBundle\Fixture;is underlined in red with the following message:

The import Doctrine\Bundle\FixturesBundle\Fixture cannot be resolved

I am stuck with this error, I do not know how to fix it. Any help would be appreciated.

like image 998
Faz Avatar asked Oct 30 '25 13:10

Faz


1 Answers

I had the same problem while using Visual Studio Code and Symfony 5. Just close the IDE, open it again and the errors are gone.

like image 71
TheDarkD Avatar answered Nov 03 '25 13:11

TheDarkD



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!