davidbadura / fixtures-bundle
A Symfony2 bundle to load yaml, json and toml fixtures. Easy extendable, resolve object dependency and validate objects.
Installs: 110 064
Dependents: 1
Suggesters: 0
Security: 0
Stars: 12
Watchers: 1
Forks: 4
Open Issues: 8
Type:symfony-bundle
Requires
- php: >=5.3.0
- davidbadura/fixtures: @beta
- symfony/symfony: ~2.1
Requires (Dev)
- davidbadura/faker-bundle: 1.0.*
Suggests
- davidbadura/faker-bundle: 1.0.*
This package is auto-updated.
Last update: 2022-07-26 07:28:56 UTC
README
The project is no longer supported. If you still want to create fixtures with yaml, then I recommend switching to Alice.
Features
- DavidBaduraFakerBundle support (documentation)
- Resolve object dependency (also bidirectional references)
- Configurable default fixture converter (constructor, properties, set* and add* methods)
- Easy to create your own converter
- Extendable by events
- Fixture filtering by tags
- Object validation
- Fixturemanager as a service
- Fixture data validating and normalizing by symfony config component
- MongoDB support
- DefaultConverter: handle "setCreateDate(\DateTime $date)" methods
- Security Encoder support
Todos
- Core components move in its own repository DavidBadura\Fixtures
- XML Fixtures support
Documentation
- Installation
Add DavidBaduraFixtureBundle in your composer.json
{ "require": { "davidbadura/fixtures-bundle": "1.0.*" } }
Add the DavidBaduraFixturesBundle to your application kernel:
// app/AppKernel.php public function registerBundles() { return array( // ... new DavidBadura\FixturesBundle\DavidBaduraFixturesBundle(), // ... ); }
- Configuration
Configure DavidBaduraFixturesBundle:
# app/config/config.yml david_badura_fixtures: bundles: [YourBundle]
Activate support for MongoDB:
# app/config/config.yml david_badura_fixtures: persister: odm
- Create fixtures
Now you must create your fixture data:
# @YourBundle/Resource/fixtures/install.yml user: properties: class: "YourBundle\Entity\User" data: david: name: David email: "d.badura@gmx.de" groups: ["@group:admin"] # <- reference to group.admin group: properties: class: "YourBundle\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();