davidbadura/fixtures-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

A Symfony2 bundle to load yaml, json and toml fixtures. Easy extendable, resolve object dependency and validate objects.

Installs: 111 429

Dependents: 1

Suggesters: 0

Security: 0

Stars: 12

Watchers: 1

Forks: 4

Open Issues: 8

Type:symfony-bundle

2.0.0-beta 2013-12-14 15:43 UTC

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.

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

  1. Load fixtures

Command:

php app/console davidbadura:fixtures:load

Service:

$fixtureManager = $container->get('davidbadura_fixtures.fixture_manager');
$fixtureManager->load();