Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A Symfony2 bundle to load yaml fixtures. Easy extendable, resolve object dependency and validate objects.
PHP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Command
DependencyInjection
EventListener
Resources
Tests
.gitignore
.travis.yml
DavidBaduraFixturesBundle.php
Factory.php
LICENSE
README.md
composer.json
phpunit.xml.dist

README.md

DavidBaduraFixturesBundle

Build Status Bitdeli Badge

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

Documentation

1. 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(),
        // ...
    );
}

2. 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

3. 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.

4. Load fixtures

Command:

php app/console davidbadura:fixtures:load

Service:

$fixtureManager = $container->get('davidbadura_fixtures.fixture_manager');
$fixtureManager->load();
Something went wrong with that request. Please try again.