GithubHelp home page GithubHelp logo

zecho / alicebundle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from baldurrensch/alicebundle

0.0 2.0 0.0 495 KB

A Symfony bundle to manage fixtures with Alice and Faker.

License: MIT License

Shell 0.22% PHP 99.78%

alicebundle's Introduction

AliceBundle

A Symfony bundle to manage fixtures with nelmio/alice and fzaninotto/Faker.

The database support is done in FidryAliceDataFixtures. Check this project to know which database/ORM is supported.

Warning: this doc is behind updated for HautelookAliceBundle 2.0. If you want to check the documentation for 1.x, head this way.

Package version Build Status SensioLabsInsight Dependency Status Scrutinizer Code Quality Code Coverage Slack

Documentation

  1. Install
  2. Basic usage
  3. Advanced usage
    1. Enabling databases
    2. Environment specific fixtures
    3. Fixtures parameters
      1. Alice parameters
      2. Application parameters
    4. Use service factories
  4. Custom Faker Providers
  5. Custom Alice Processors
  6. Resources

Other references:

Installation

Example of installation:

# If you are using Symfony standard edition, you can skip this step
composer require doctrine/doctrine-bundle doctrine/orm:^2.5

composer require --dev hautelook/alice-bundle:^2.0@beta \
  nelmio/alice:^3.0@beta \
  theofidry/alice-data-fixtures:^1.0@beta \
  doctrine/data-fixtures

Explanation: HautelookAliceBundle uses FidryAliceDataFixtures for the persistence layer. As FidryAliceDataFixtures is compatible with different databases/ORM, one cannot be installed by default. In the example above, we are using Doctrine ORM which requires doctrine/orm doctrine/orm-bundle doctrine/data-fixtures.

Then, enable the bundle by updating your app/AppKernel.php file to enable the bundle:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = [
        new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
        // ...
        new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
    ];
    
    if (in_array($this->getEnvironment(), ['dev', 'test'])) {
        //...
        $bundles[] = new Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle();
        $bundles[] = new Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle();
        $bundles[] = new Hautelook\AliceBundle\HautelookAliceBundle();
    }

    return $bundles;
}

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

# app/config/config_dev.yml

hautelook_alice:
    fixtures_path: 'Resources/fixtures/orm' # Path to which to look for fixtures relative to the project directory or the bundle path.

Basic usage

Assuming you are using Doctrine, make sure you have the doctrine/doctrine-bundle and doctrine/data-fixtures packages installed.

Then create a fixture file in app/Resources/fixtures/orm:

# app/Resources/fixtures/orm/dummy.yml

AppBundle\Entity\Dummy:
    dummy_{1..10}:
        name: <name()>
        related_dummy: '@related_dummy*'
# app/Resources/fixtures/orm/related_dummy.yml

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

Then simply load your fixtures with the doctrine command php bin/console hautelook:fixtures:load.

If you want to load the fixtures of a bundle only, do php bin/console hautelook:fixtures:load -b MyFirstBundle -b MySecondBundle.

See more.
Next chapter: Advanced usage

Resources

Credits

This bundle was originaly developped by Baldur RENSCH and HauteLook. It is now maintained by Théo FIDRY.

Other contributors.

License

license

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.