PHPackages                             durimjusaj/alice-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. durimjusaj/alice-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

durimjusaj/alice-bundle
=======================

Symfony bundle to manage fixtures with Alice and Faker.

1.3(1y ago)085MITPHPPHP ^8

Since Mar 6Pushed 1y agoCompare

[ Source](https://github.com/durimjusaj/AliceBundle)[ Packagist](https://packagist.org/packages/durimjusaj/alice-bundle)[ RSS](/packages/durimjusaj-alice-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (13)Versions (5)Used By (0)

AliceBundle
===========

[](#alicebundle)

A [Symfony](http://symfony.com) bundle to manage fixtures with [nelmio/alice](https://github.com/nelmio/alice) and [fzaninotto/Faker](https://github.com/fzaninotto/Faker).

The database support is done in [FidryAliceDataFixtures](https://github.com/theofidry/AliceDataFixtures). Check this project to know which database/ORM is supported.

**Warning: this is the documentation for HautelookAliceBundle 2.0. If you want to check the documentation for 1.x, head [this way](https://github.com/theofidry/AliceBundle/tree/1.x).**

[![Package version](https://camo.githubusercontent.com/a5ca9621dd34735686069a9d10ebcfa54d2a759d0bed98f5407468f7eb3d8035/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68617574656c6f6f6b2f616c6963652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hautelook/alice-bundle)[![Build Status](https://camo.githubusercontent.com/8e7451b0f15f287d1677965fed637cbc868827b7b69ddb0fda4dfb79f05f16f2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7468656f66696472792f416c69636542756e646c652f43492e7376673f7374796c653d666c61742d737175617265)](https://github.com/theofidry/AliceBundle/actions)[![SensioLabsInsight](https://camo.githubusercontent.com/17f23f6ebef5bec3b2eb4242f715beda7f88f6bcf3de6fbdc0b7c08f9cef2f80/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f64393361336663342d336665382d346265332d616136322d3330376635333839383139392e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/d93a3fc4-3fe8-4be3-aa62-307f53898199)[![Dependency Status](https://camo.githubusercontent.com/46560d9467d9cd8a8ec9299c781c05cc952ef3e26cf3c9f46363aa3c1561f2a2/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3535643236343738323635666636303031613030303038342f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/55d26478265ff6001a000084)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5dc6c93c425233cde1cd3d78b429fb5bfebcfc31d6b4bc4c1ec71c388f80e128/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f68617574656c6f6f6b2f416c69636542756e646c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/hautelook/AliceBundle/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/dbf0d560e56aebe731f44cc862392acf7f2cc4c945ff5e49b4a5c3acf3ecb9f9/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f68617574656c6f6f6b2f416c69636542756e646c652e7376673f623d6d6173746572267374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/hautelook/AliceBundle/?branch=master)[![Slack](https://camo.githubusercontent.com/a417e9b124e072be924465ed963504c2acc9d5f643b71ed4fd4d8378eb654c73/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736c61636b2d253233616c6963652d2d66697874757265732d7265642e7376673f7374796c653d666c61742d737175617265)](https://symfony-devs.slack.com/shared_invite/MTYxMjcxMjc0MTc5LTE0OTA3ODE4OTQtYzc4NWVmMzRmZQ)

When to use this bundle?
------------------------

[](#when-to-use-this-bundle)

HautelookAliceBundle changed a lot, it first was acting as a simple bundle for [nelmio/alice](https://github.com/nelmio/alice), it then started to ship some additional features to enrich it.

HautelookAliceBundle 1.x was the first milestone reaching a certain level of maturity in its usage:

- Easily load a set of fixtures from a command
- Being able to define different sets of fixtures for multiple environments
- Customize the data generation with custom Faker providers
- Customize the loading behaviour with processors

HautelookAliceBundle 2.x changes a lot, although not so much. In 1.x, a lot of complexity was brought in the bundle due to nelmio/alice 2.x limitations and were at best workarounds (like the lack of handling of circular references). A lot of that complexity has been pushed back to nelmio/alice 3.x which has a much more flexible design. As a result:

- [nelmio/alice](https://github.com/nelmio/alice) 3.x allows you to easily create PHP objects with random data in an elegant way
- [FidryAliceDataFixtures](https://github.com/theofidry/AliceDataFixtures) is a persistence layer for nelmio/alice 3.x. If you need to persist the loaded objects, it is the package you need. It provides you the flexibility to be able to purge the data between each loadings or wrap the loading in a transaction for your tests for example to simply rollback once the test is finished instead of calling an expansive purge.
- hautelook/alice-bundle 2.x provides high-level features including fixtures discovery (find the appropriate files and load them), and helpers for database testing. If you just need to load specific sets of files for your tests, [FidryAliceDataFixtures](https://github.com/theofidry/AliceDataFixtures) is enough.

Documentation
-------------

[](#documentation)

1. [Install](#installation)
2. [Basic usage](#basic-usage)
3. [Database testing](#database-testing)
4. [Advanced usage](doc/advanced-usage.md)
    1. [Enabling databases](doc/advanced-usage.md#enabling-databases)
    2. [Environment specific fixtures](doc/advanced-usage.md#environment-specific-fixtures)
    3. [Fixtures parameters](doc/advanced-usage.md#fixtures-parameters)
        1. [Alice parameters](doc/advanced-usage.md#alice-parameters)
        2. [Application parameters](doc/advanced-usage.md#application-parameters)
    4. [Use service factories](doc/advanced-usage.md#use-service-factories)
    5. [Load fixtures in a specific order](doc/advanced-usage.md#load-fixtures-in-a-specific-order)
        1. [Load fixtures in a specific order](doc/advanced-usage.md#ordering-the-files-found)
        2. [Persisting the classes in a specific order](doc/advanced-usage.md#persisting-the-classes-in-a-specific-order)
    6. [Validation](doc/advanced-usage.md#validation)
5. [Custom Faker Providers](doc/faker-providers.md)
6. [Custom Alice Processors](doc/alice-processors.md)
7. [Resources](#resources)

Installation
------------

[](#installation)

With [Symfony Flex](https://symfony.com/doc/current/setup/flex.html) (recommended):

```
# If you do not have Doctrine installed yet:
composer require doctrine-orm

composer require --dev hautelook/alice-bundle

```

You're ready to use AliceBundle, and can jump to the next section!

Without Flex you will have to install `doctrine/orm` and register the bundles accordingly in `app/AppKernel.php` or wherever your Kernel class is located:

```
