Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2, How to load fixtures with --fixtures option?

Tags:

symfony

I need an example for command below in Symfony2 :

php app/console doctrine:mongodb:fixtures:load --fixtures=/path/to/fixture 

I don't know how to set the --fixtures=/path/to/fixture. I can load all together but I cannot do it for only one new fixture !

What format should /path/to/fixture be ?

Also I tried this --fixtures=src/PMI/UserBundle/DataFixtures/ORM/FeatureFixtures but I get this every time :

 [InvalidArgumentException]                             
  Could not find any fixtures to load in:                               
  - src/PMI/UserBundle/DataFixtures/ORM/FeatureFixtures
like image 456
pmoubed Avatar asked May 23 '12 20:05

pmoubed


3 Answers

I know this is old but other people have asked and these answers may not cover some of the other questions.

You only need to specify the folder, not the file. In the above question, its not clear if FeatureFixtures is the php file or actually a folder. It may be failing if that is only a php file and not a folder. This is the correct way to load the fixtures assuming that FeatureFixtures is a php file with the fixtures:

doctrine:fixtures:load --fixtures=src/PMI/UserBundle/DataFixtures/ORM --append
like image 147
George Avatar answered Nov 11 '22 07:11

George


You can define a fixture with the real path.

php app/console doctrine:fixtures:load --fixtures=src/MyBundle/DataFixtures/ORM/LoadMyFixturesData.php
like image 36
nicovak Avatar answered Nov 11 '22 06:11

nicovak


It's not require but if you want to manually specify the directory where the fixtures classes should be loaded you can use this :

for example if I execute a command in directory symfony

--fixtures=/src/yourBundle/fixture 
like image 39
a.aitboudad Avatar answered Nov 11 '22 06:11

a.aitboudad