- Installation
Add DavidBadura Fixtures in your composer.json
{
"require": {
"davidbadura/fixtures": "~1.0"
}
}
Add the DavidBaduraFixturesBundle to your application kernel:
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new DavidBadura\Fixtures\Extension\Symfony\DavidBaduraFixturesBundle(),
// ...
);
}
- Configuration
Configure DavidBaduraFixturesBundle:
# app/config/config.yml
david_badura_fixtures:
bundles: [AppBundle]
Activate support for MongoDB:
# app/config/config.yml
david_badura_fixtures:
persister: odm
- Create fixtures
Now you should create your fixture data:
# @AppBundle/Resource/fixtures/install.yml
user:
properties:
class: "AppBundle\Entity\User"
data:
david:
name: David
email: "[email protected]"
groups: ["@group:admin"] # <- reference to group.admin
group:
properties:
class: "AppBundle\Entity\Group"
data:
admin:
name: Admin
member:
name: Member
The fixture files will be automatically loaded from the Resources\fixtures
folder.
- Load fixtures
Command:
php app/console davidbadura:fixtures:load
Service:
$fixtureManager = $container->get('davidbadura_fixtures.fixture_manager');
$fixtureManager->load();