2017 © Pedro PelĂĄez
 

symfony-bundle alice-bundle

Symfony2 Bundle to manage fixtures with Alice and Faker.

image

lichnow/alice-bundle

Symfony2 Bundle to manage fixtures with Alice and Faker.

  • Saturday, January 30, 2016
  • by lichnow
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

AliceBundle

A Symfony bundle to manage fixtures with nelmio/alice and fzaninotto/Faker., (*1)

Currently supports Doctrine ORM, Doctrine ODM, Doctrine PHPCR ODM., (*2)

Package version Build Status SensioLabsInsight Dependency Status Scrutinizer Code Quality Code Coverage HHVM support, (*3)

Gitter, (*4)

Documentation

  1. Install
  2. Basic usage
  3. Advanced usage
    1. Enabling databases
    2. Fixtures parameters
    3. Doctrine ORM
    4. Doctrine ODM (MongoDB)
    5. Doctrine PHPCR ODM
  4. Custom Faker Providers
    1. Simple Provider
    2. Advanced Provider
  5. Custom Alice Processors
  6. DoctrineFixturesBundle support
  7. Resources

Other references:, (*5)

Installation

First you need install appropriate database managers (if you didn't install it yet), according to your project requirements. Check the documentation here., (*6)

You can use Composer to install the bundle to your project:, (*7)

composer require --dev hautelook/alice-bundle

Then, enable the bundle by updating your app/config/AppKernel.php file to enable the bundle:, (*8)

<?php
// app/config/AppKernel.php

public function registerBundles()
{
    //...
    if (in_array($this->getEnvironment(), ['dev', 'test'])) {
        //...
        $bundles[] = new Hautelook\AliceBundle\HautelookAliceBundle();
    }

    return $bundles;
}

Configure the bundle to your needs (example with default values):, (*9)

# app/config/config_dev.yml

hautelook_alice:
    db_drivers:
        orm: ~          # Enable Doctrine ORM if is registered
        mongodb: ~      # Enable Doctrine ODM if is registered
        phpcr: ~        # Enable Doctrine PHPCR ODM if is registered
    locale: en_US       # Locale to used for faker; must be a valid Faker locale otherwise will fallback to en_EN
    seed: 1             # A seed to make sure faker generates data consistently across runs, set to null to disable
    persist_once: false # Only persist objects once if multiple files are passed
    loading_limit: 5    # Maximum number of time the loader will try to load the files passed

Fore more information regarding the locale, refer to Faker documentation on localization., (*10)

Basic usage

Assuming you are using Doctrine, install the doctrine/doctrine-bundle and doctrine/data-fixtures packages and register both bundles. Then create a fixture file in AppBundle/DataFixtures/ORM:, (*11)

# AppBundle/DataFixtures/ORM/dummy.yml

AppBundle\Entity\Dummy:
    dummy_{1..10}:
        name: <name()>
        related_dummy: @related_dummy*
# AppBundle/DataFixtures/ORM/related_dummy.yml

AppBundle\Entity\RelatedDummy:
    related_dummy_{1..10}:
        name: <name()>

Then simply load your fixtures with the doctrine command php app/console hautelook_alice:doctrine:fixtures:load (or php app/console h:d:f:l)., (*12)

If you want to load the fixtures of a bundle only, do php app/console h:d:f:l -b MyFirstBundle -b MySecondBundle., (*13)

See more.
Next chapter: Advanced usage, (*14)

Resources

Credits

This bundle was originaly developped by Baldur RENSCH and HauteLook. It is now maintained by Théo FIDRY., (*15)

Other contributors., (*16)

License

license, (*17)

The Versions