This bundle requires Symfony 2.1+
- Download SpFixtureDumperBundle using composer
- Enable the Bundle
- Dump fixtures from database
Add SpFixtureDumperBundle in your composer.json:
{
"require": {
"sp/fixture-dumper-bundle": "dev-master"
}
}Now tell composer to download the bundle by running the command:
php composer.phar update sp/fixture-dumper-bundleComposer will install the bundle to your project's vendor/sp directory.
Enable the bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Sp\FixtureDumperBundle\SpFixtureDumperBundle(),
);
}You can dump fixtures from existing entities via the command
php app/console sp:fixture-dumper:orm /path/to/fixturesIf you're using the ODM, use the sp:fixture-dumper:mongodb command instead:
php app/console sp:fixture-dumper:mongodb /path/to/fixturesBoth commands come with a few options:
-
--format=yml- Use this option to manually specify the format for the dumped fixtures. There are currently three implemented- class (default) - Dump class fixtures
- yml - Dump yml fixtures which can be loaded with the alice library
- array - Dump php array fixtures which can be loaded with the alice library
-
--single-file- Use this flag to dump all fixtures into one file -
--em=manager_name- Manually specify the entity manager to use for loading the data.
Note: If using the sp:fixture-dumper:mongodb task, replace the --em=
option with --dm= to manually specify the document manager.
A full example use might look like this:
php app/console sp:fixture-dumper:orm --format=yml --single-file --em=foo_manager /path/to/fixtures