Symfony 3.4.0 Could not find any fixture services to load

symfony 4 fixtures
symfony fixtures
symfony fixtures group
symfony fixtures getdependencies
run data fixtures symfony
fixtures bundle symfony 4
doctrine load fixtures order
doctrine:fixtures:load single file

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 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']

doctrine, 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  @bocharsky-bw I do know about the --em option … My issue is: whatever the entity Manager name I pass through that option, ALL registered FixturesLoader services are retrieved and their respective load method get called with the supplied entity manager.


I tried @Alexander's solution but it's doesn't work for me.

I had resolved the same problem by adding the tag service to the class, Symfony doc on the services.yml file bundle:

BlogBundle/Resources/config/services.yml

Services:
...
# Fixtures services
    BlogBundle\DataFixtures\ORM\PostFixture:
        tags: [doctrine.fixture.orm]
...

My BlogBundle/DataFixtures/ORM/PostFixture.php class :

...
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
...

class PostFixture implements FixtureInterface
{
public function load(ObjectManager $manager)
    {
...
}
}

Source Inspiration : Synfony doc -> Service container -> The autoconfigure Option

Hope it'll an alternative solution

Could not find any fixture services to load. · Issue #728 · symfony , After changing .env to mysql doctrine:schema:create finished successful. doctrine​:fixtures:load Could not find any fixture services to load. datafixtures - Symfony 3.4.0 Could not find any fixture services to load symfony 4 fixtures (6) After long research, found a solution.


Example for reusable bundle.

src/Acme/Bundle/UserBundle/DataFixtures/ORM/DataFixtures.php

<?php 
namespace Acme\Bundle\UserBundle\DataFixtures\ORM;

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

class DataFixtures extends Fixture
{
    /**
     * Load data fixtures with the passed EntityManager
     *
     * @param ObjectManager $manager
     */
    public function load(ObjectManager $manager)
    {
       #your code
    }
}

in app/config/services.yml

Acme\Bundle\UserBundle\DataFixtures\:
     resource: '../../src/Acme/Bundle/UserBundle/DataFixtures/'

append your fixtures data:

php bin/console doctrine:fixtures:load --append

Could not find any fixture services to load – GiveMeAns – Get the , Fixtures Bundle issue with bundle version 3.0 Symfony 3.4.0 Could not find any fixture services to load Symfony Doctrine can't find fixtures to  I'm using symfony 3.4.x with doctrine/doctrine-fixtures-bundle": "^3.0 and when I try to run command: php bin/console doctrine:fixtures:load getting the error: could not find any fixture services to load


~/dev/domain.lan/src/ProductBundle/DataFixtures/ORM/ProductF‌​ixture.php

<?php

namespace ProductBundle\DataFixtures\ORM;

use Doctrine\Bundle\FixturesBundle\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use ProductBundle\Entity\Product;

class ProductFixture implements FixtureInterface
{

    public function load(ObjectManager $manager)
    {
       // create 20 products! Bam!
       for ($i = 0; $i < 20; $i++) {
           $product = new Product();
           $product->setName('Product name' . $i);
           $manager->persist($product);
       }

       $manager->flush();
    }
}

The problem is solved it was necessary to add a service: (app/config/services.yml)

services:
    # Product service
    ProductBundle\:
        resource: '../../src/ProductBundle/*'
        exclude: '../../src/ProductBundle/{Entity,Repository,Tests}'

Could not find any fixture services to load, 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? No, it doesn't work for me. Maybe it works with Symfony >=3.4. I think I need to manually tag "doctrine.fixture.orm" but I don't know how to do that.


In 4.0.1 I have to implement service configuration to show Symfony my DataFixtures folder:

in config/services.yaml

services:

    ...

    App\DataFixtures\:
        resource: '../src/DataFixtures'
        tags: [doctrine.fixture.orm]

if my class IMPLEMENTS FixtureInterface and without this config if it is EXTENDS Fixture

Fixtures: Dummy Data Rocks > Symfony 3: Doctrine & the Database , Symfony 3.4 and Fixtures Bundle issue with bundle version 3.0 Symfony 3.4.0 Could not find any fixture services to load Symfony Doctrine can't find fixtures to  [InvalidArgumentException] Could not find any fixtures services to load. Bien sûr, je pense que cela exclut les problèmes d'installation de doctrine, j'ai également essayé à plusieurs reprises de vider le cache au cas où, rien n'y fait. Voici le code source de ma fixture LoadCategory.php :


Making Fixtures Awesome with Alice > Making Fixtures Really , Regarding same error ("Could not find any fixture services to load") when you use Symfony 3.4: to solve it, you just need to have the fixtures class extend the  php bin/console doctrine:fixtures:load. Voici ce qui s'affiche : C:\wamp64\www\Symfony>php bin/console doctrine:fixtures:load Careful, database will be purged. Do you want to continue y/N ?y [InvalidArgumentException] Could not find any fixture services to load.


DoctrineFixturesBundle (Symfony Bundles Docs), For example you can see our numberBetween , sentence and even some things for creating random names where you can choose which gender you want. So  Starting from Symfony 4.0, Flex should be used by default and register the bundle for you, and in that case you can skip to the next section and start writing fixtures. In Symfony 3 applications (or when not using Symfony Flex), run this other command instead:


Fixtures are used to load a "fake" set of data into a database that can then be used for In Symfony 3 applications (or when not using Symfony Flex), run this other command instead: To see other options for the command, run: In some cases you may need to access your application's services inside a fixtures class. This makes the bundle - and any services, commands, etc that it gives us - not available in the prod environment. That's fine for us - this is a development tool - and it keeps the prod environment a little smaller. Creating the Fixture Class. Anyways, this bundle gives us a new console command - doctrine:fixtures:load.