Doctrine load fixtures – How to load particular fixture

Doctrine load fixtures – How to load particular fixture

Symfony has an option to load fixtures from command line:

$ php app/console doctrine:fixtures:load --help
Usage:
 doctrine:fixtures:load [--fixtures[="..."]] [--append] [--em="..."] [--purge-with-truncate]

Options:
 --fixtures             The directory or file to load data fixtures from. (multiple values allowed)
 --append               Append the data fixtures instead of deleting all data from the database first.
 --em                   The entity manager to use for this command.
 --purge-with-truncate  Purge data by using a database-level TRUNCATE statement
 --help (-h)            Display this help message.
 --quiet (-q)           Do not output any message.
 --verbose (-v|vv|vvv)  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
 --version (-V)         Display this application version.
 --ansi                 Force ANSI output.
 --no-ansi              Disable ANSI output.
 --no-interaction (-n)  Do not ask any interactive question.
 --shell (-s)           Launch the shell.
 --process-isolation    Launch commands from shell as a separate process.
 --env (-e)             The Environment name. (default: "test")
 --no-debug             Switches off debug mode.

But if you assign the full path to fixture file with --fixtures option, its not going to load it and you’ll end up with error:

[InvalidArgumentException]
Could not find any fixtures to load in:
– full/path/to/file.php

The other option is to load the folder itself by typing the full path to folder where fixture file resides.

php app/console doctrine:fixtures:load --fixture=/src/BundleName/DataFixtures/ORM/
Total Views: 27 ,