Skip to content

Could not find any fixture services to load. #728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lbm-services opened this issue Dec 9, 2017 · 18 comments
Closed

Could not find any fixture services to load. #728

lbm-services opened this issue Dec 9, 2017 · 18 comments

Comments

@lbm-services
Copy link

After changing .env to mysql doctrine:schema:create finished successful.
doctrine:fixtures:load
Could not find any fixture services to load.

@javiereguiluz
Copy link
Member

The fixtures of this app are stored in src/DataFixtures/, which doesn't work when the DoctrineFixturesBundle is old. We recently update this bundle to 3.0.2 version. Are you using the same version?

Independently from the previous comment, you can execute the command as follows to make it work no matter which version of fixtures bundle you use:

$ php bin/console doctrine:fixtures:load --fixtures=src/DataFixtures/

@DavertMik
Copy link

Thanks, but I get this

php bin/console doctrine:fixtures:load --fixtures=src/DataFixtures/

                                           
  The "--fixtures" option does not exist.  
                                           

doctrine:fixtures:load [--append] [--em EM] [--shard SHARD] [--purge-with-truncate] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

Current package set:

doctrine/cache                      v1.7.1            Caching library offering an object-oriented API for many cache backends
doctrine/collections                v1.5.0            Collections Abstraction library
doctrine/common                     v2.8.1            Common Library for Doctrine projects
doctrine/data-fixtures              v1.3.0            Data Fixtures for all Doctrine Object Managers
doctrine/dbal                       v2.6.3            Database Abstraction Layer
doctrine/doctrine-bundle            1.8.1             Symfony DoctrineBundle
doctrine/doctrine-cache-bundle      1.3.2             Symfony Bundle for Doctrine Cache
doctrine/doctrine-fixtures-bundle   3.0.1             Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle v1.3.1            Symfony DoctrineMigrationsBundle

@DavertMik
Copy link

Same behavior with

doctrine/doctrine-fixtures-bundle   3.0.2             Symfony DoctrineFixturesBundle

See:

php bin/console doctrine:fixtures:load       
Careful, database will be purged. Do you want to continue y/N ?y

In LoadDataFixturesDoctrineCommand.php line 95:
                                                
  Could not find any fixture services to load.  
                                                

doctrine:fixtures:load [--append] [--em EM] [--shard SHARD] [--purge-with-truncate] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

@lbm-services
Copy link
Author

Why don t you guys simply provide an sql file for mysql users? Nobody wants to work with sqlite, I guess.

@bocharsky-bw
Copy link
Contributor

bocharsky-bw commented Dec 11, 2017

@lbm-services The answer is simple, this demo version should work in one click, I mean composer create-project, i.e. we don't want to enforce users to do extra steps to bootstrap this project like making sure they have MySQL server, creating DB, creating schema, loading fixtures etc. that's why SQLite DB with dummy data fits perfect here

@lbm-services
Copy link
Author

I guessed that, I mean as an OPTION.
Anyway, I made my own dumps from sqlite and imported them to MySQL. Then I ran into the pagerfanta issue (#683).
But with some adjustments and bypassing the findLatest-Method, it worked.

@phpeek
Copy link
Contributor

phpeek commented Dec 11, 2017

@lbm-services It would be a good idea to create a dockerized fork of symfony/demo and run it with mysql, if You want to give a try ! ;)

@bocharsky-bw
Copy link
Contributor

@lbm-services Actually, you don't need any SQL file at all if you prefer MySQL. Just tweak DB credentials and use console commands:

bin/console d:d:c
bin/console d:s:c
bin/console d:f:l

That's it, you'll have the same dummy data you see in SQLite

@javiereguiluz
Copy link
Member

Let's close this because when using the latest DoctrineFixturesBundle (as recommended by this app) you no longer see this error. If you still see this problem, please tell us your DoctrineFixturesBundle version and the steps to reproduce. Thanks!

@gunvantaspl
Copy link

gunvantaspl commented Jan 3, 2018

@lbm-services I also get same problem and solve it by assigning tag to the fixture. Please see the solution https://stackoverflow.com/questions/47613979/symfony-3-4-0-could-not-find-any-fixture-services-to-load/48049905#48049905

@stphane
Copy link

stphane commented Apr 5, 2018

I have two fixtures-loader services registered in a configuration file, each depending on a specific doctrine database connection.
Does anybody know how to target a specific fixture loader service using doctrine:fixtures:load command?

@bocharsky-bw
Copy link
Contributor

You probably have 2 entity managers, so you can use --em option to specify the proper entity manager for this command

@stphane
Copy link

stphane commented Apr 5, 2018

@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.
But I have two entity managers, each one is associated to a particular DBAL connection and each have its own FixturesLoader file (class).
For each entity manager I need to load of the appropriate/associated FixturesLoader (service). Does this make more sense to you? Thank you.

@bocharsky-bw
Copy link
Contributor

Hm, what about to pass an entity manager into all fixture loaders and add a custom logic at the beginning of load() method, i.e. if loader does not support current entity manager - just do a return, otherwise - load fixtures?

@stphane
Copy link

stphane commented Apr 5, 2018

Lol that's exactly my workaround solution at the moment.

if (strtolower($manager->getConnection()->getDatabase()) != 'acme') {
    return;
}

But this do feel like a workaround and not a proper solution to me.
It is the responsibility of the doctrine-fixtures-bundle (a upper level context) to feed the service with the appropriate manager and not the fixtureLoader itself IMO.
Some sort of a service id or glob option on the command whould do the trick I guess.

@bocharsky-bw
Copy link
Contributor

Then probably better to create an issue in DoctrineFixturesBundle instead or make a PR :)

@flik
Copy link

flik commented May 9, 2018

https://symfony.com/doc/master/bundles/DoctrineFixturesBundle/index.html follow the documentation It is fixed.

@rumours86
Copy link

I've created a PR: doctrine/DoctrineFixturesBundle#250

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants