2017 © Pedro Peláez
 

library fixtures

A library to load yaml, json or php fixtures. Easy extendable, resolve object dependency and validate objects.

image

davidbadura/fixtures

A library to load yaml, json or php fixtures. Easy extendable, resolve object dependency and validate objects.

  • Sunday, January 28, 2018
  • by DavidBadura
  • Repository
  • 3 Watchers
  • 13 Stars
  • 13,057 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 6 Forks
  • 1 Open issues
  • 7 Versions
  • 9 % Grown

The README.md

davidbadura\fixtures

Build Status Latest Stable Version Total Downloads License, (*1)

Features:, (*2)

  • Use Services like fzaninotto/Faker, a PHP library that generates fake data for you
  • Resolve object dependency automatically (also bidirectional references)
  • Configurable default fixture converter (constructor, properties, set* and add* methods)
  • Easy to create your own converter
  • Many fixtures loader: Yaml, Json, Toml und PHP
  • Extendable by events (currently with symfony/event-dispatcher)
  • Fixture filtering by tags
  • Object validation (currently with symfony/validator over events)
  • Persist Fixtures with Doctrine ORM, Doctrine MongoDb or Propel
  • Easy to add your own Persister
  • Use an expression-language with symfony/expression-language

Todos:, (*3)

  • Add cli functionality.
  • Translate documentation ( my english is really bad ;) )
  • Write documentation

Documentation

Installation

You can easily install this package over composer, (*4)

composer require 'davidbadura/fixtures'

Useage

First, you must create fixtures files in yaml, json, toml, php or mixed. In this example, we have different formats:, (*5)

YAML, (*6)


user: properties: class: DavidBadura\Fixtures\TestObjects\User constructor: [name, email] data: david: name: "David Badura" email: "d.badura@gmx.de" group: ["@group:owner", "@group:developer"] role: ["@role:admin"] other: name: "Somebody" email: "test@example.de" group: ["@group:developer"] role: ["@role:user"]

PHP, (*7)


<?php return array( 'role' => array( 'properties' => array( 'class' => 'DavidBadura\\Fixtures\\TestObjects\\Role', ), 'data' => array( 'admin' => array( 'name' => 'Admin', ), 'user' => array( 'name' => 'User', ), ), ) );

JSON, (*8)


{ "group": { "properties": { "class": "DavidBadura\\Fixtures\\TestObjects\\Group" }, "data": { "developer": { "name": "Developer", "leader": "@@user:david" } } } }

You can reference to other objects with following expression @{fixture-name}:{fixture-key}. The references will resolved automatically., (*9)

What other formats are supported you can read under Loader., (*10)

How the fixture manager converte the fixtures to objects can you read in the Converter section. You can use the default fixture converter or write your own converter., (*11)

Load Fixtures, (*12)

Now, you can load the fixtures, crate the objects and persist these in the database. For this, we use the default fixture manager., (*13)


use DavidBadura\Fixtures\FixtureManager\FixtureManager; // $objectManager can be curently Doctrine ORM Entity Manager or other Doctrine DocumentManager like MongoODM or CouchODM $fixtureManager = FixtureManager::createDefaultFixtureManager($objectManager); $fixtureManager->load('path/to/fixtures');

You can easily instance your own fixture manager. For more information you can read FixtureManager documentation., (*14)

The Versions

28/01 2018
02/11 2016

1.1.0

1.1.0.0

A library to load yaml, json or php fixtures. Easy extendable, resolve object dependency and validate objects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Badura

orm mongodb database json events doctrine fixtures yaml faker puli

30/10 2015

1.0.0

1.0.0.0

A library to load yaml, json or php fixtures. Easy extendable, resolve object dependency and validate objects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Badura

orm mongodb database json events doctrine fixtures yaml faker puli

14/12 2013

1.0.0-beta2

1.0.0.0-beta2

A library to load yaml, json or php fixtures. Easy extendable, resolve object dependency and validate objects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Badura

orm mongodb database json events doctrine fixtures yaml faker

06/11 2013

1.0.0-beta

1.0.0.0-beta

A library to load yaml, json or php fixtures. Easy extendable, resolve object dependency and validate objects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Badura

orm mongodb database json events doctrine fixtures yaml faker