zac
zac

Reputation: 4898

error when I try to load a fixture

When I try to run the load method in the console I get this error:

[InvalidArgumentException]

Could not find any fixture services to load.

I created under my AppBundle folders DataFixtures\ORM so why I get this error ?

Also when I have more than one bundle how I can tell Symfony which fixture to load ?

namespace AppBundle\DataFixtures\ORM;


use AppBundle\Entity\Movie;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;

class LoadMovieData implements FixtureInterface
{

    /**
     * Load data fixtures with the passed EntityManager
     *
     * @param ObjectManager $manager
     */
    public function load(ObjectManager $manager)
    {
        $movie = new Movie();
        $movie->setTitle('Green Mile');
        $movie->setDescription('fdgs sdfg sdg');
        $movie->setTime(23);
        $movie->setYear(2341);

        $manager->persist($movie);
        $manager->flush();
    }
}

Upvotes: 0

Views: 1449

Answers (2)

Flo
Flo

Reputation: 356

Did you try to append Fixture to both your file and class :

AppBundle\DataFixtures\ORM\LoadMovieDataFixture.php

class LoadMovieDataFixture

Upvotes: 0

Sergei Kutanov
Sergei Kutanov

Reputation: 825

There's an update to the fixtures bundle since 3.0 http://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html

You don't implement FixturesInterface but extend Fixutres class -

use Doctrine\Bundle\FixturesBundle\Fixture;
class LoadMovieData extends Fixture {}

Upvotes: 1

Related Questions