Relying on fzaninotto/Faker, Alice allows you to create a ton of fixtures/fake data for use while developing or testing your project. It gives you a few essential tools to make it very easy to generate complex data with constraints in a readable and easy to edit way, so that everyone on your team can tweak the fixtures if needed.

Code Quality Rank: L4
Programming language: PHP
License: MIT License
Tags: Testing     Test     ORM     Data     Faker     Fixture    
Latest version: v3.7.4

Alice alternatives and similar libraries

Based on the "Testing" category.
Alternatively, view Alice alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Alice or a related project?

Add another 'Testing' Library


Alice - Expressive fixtures generator

Package version Build Status Slack [License](LICENSE)

Relying on FakerPHP/Faker, Alice allows you to create a ton of fixtures/fake data for use while developing or testing your project. It gives you a few essential tools to make it very easy to generate complex data with constraints in a readable and easy to edit way, so that everyone on your team can tweak the fixtures if needed.

Warning: this doc is for alice 3.0. If you want to check the documentation for 2.x, follow this link.

2.x is in maintenance mode: PRs are accepted, but no active development is done on it by the maintainers any longer.

Table of Contents

  1. Installation
  2. Example
  3. [Getting Started](doc/getting-started.md)
    1. [Basic Usage](doc/getting-started.md#basic-usage)
    2. [Framework integration](doc/getting-started.md#framework-integration)
      1. [Symfony](doc/getting-started.md#symfony)
  4. [Complete Reference](doc/complete-reference.md)
    1. [Creating Fixtures](doc/complete-reference.md#creating-fixtures)
      1. [YAML](doc/complete-reference.md#yaml)
      2. [PHP](doc/complete-reference.md#php)
      3. [JSON](doc/complete-reference.md#json)
    2. [Fixture Ranges](doc/complete-reference.md#fixture-ranges)
    3. [Fixture Lists](doc/complete-reference.md#fixture-lists)
    4. [Fixture Reference](doc/complete-reference.md#fixture-reference)
    5. [Calling Methods](doc/complete-reference.md#calling-methods)
      1. [Method arguments with flags](doc/complete-reference.md#method-arguments-with-flags)
      2. [Method arguments with parameters](doc/complete-reference.md#method-arguments-with-parameters)
    6. [Specifying Constructor Arguments](doc/complete-reference.md#specifying-constructor-arguments)
    7. [Using a factory / a named constructor](doc/complete-reference.md#using-a-factory--a-named-constructor)
    8. [Optional Data](doc/complete-reference.md#optional-data)
    9. [Handling Unique Constraints](doc/complete-reference.md#handling-unique-constraints)
  5. [Handling Relations](doc/relations-handling.md)
    1. [References](doc/relations-handling.md#references)
    2. [Multiple References](doc/relations-handling.md#multiple-references)
    3. [Self reference](doc/relations-handling.md#self-reference)
    4. [Passing references to providers](doc/relations-handling.md#passing-references-to-providers)
  6. [Keep Your Fixtures Dry](doc/fixtures-refactoring.md)
    1. [Fixture Inheritance](doc/fixtures-refactoring.md#fixture-inheritance)
    2. [Including files](doc/fixtures-refactoring.md#including-files)
    3. [Variables](doc/fixtures-refactoring.md#variables)
    4. [Parameters](doc/fixtures-refactoring.md#parameters)
      1. [Static parameters](doc/fixtures-refactoring.md#static-parameters)
      2. [Dynamic parameters](doc/fixtures-refactoring.md#dynamic-parameters)
      3. [Composite parameters](doc/fixtures-refactoring.md#composite-parameters)
      4. [Usage with functions (constructor included)](doc/fixtures-refactoring.md#usage-with-functions-constructor-included)
      5. [Inject external parameters](doc/fixtures-refactoring.md#inject-external-parameters)
  7. [Customize Data Generation](doc/customizing-data-generation.md)
    1. [Faker Data](doc/customizing-data-generation.md#faker-data)
      1. [Localized Fake Data](doc/customizing-data-generation.md#localized-fake-data)
      2. [Random data](doc/customizing-data-generation.md#random-data)
      3. [Default Providers](doc/customizing-data-generation.md#default-providers)
        1. [Identity](doc/customizing-data-generation.md#identity)
        2. [Current](doc/customizing-data-generation.md#current)
        3. [Cast](doc/customizing-data-generation.md#cast)
    2. [Custom Faker Data Providers](doc/customizing-data-generation.md#custom-faker-data-providers)
  8. [Advanced Guide](doc/advanced-guide.md#advanced-guide)
    1. [Performance](doc/advanced-guide.md#performance)
    2. [Expression Language (DSL)](doc/advanced-guide.md#expression-language-dsl)
      1. [Parameters](doc/advanced-guide.md#parameters)
      2. [Functions](doc/advanced-guide.md#functions)
      3. [Identity](doc/advanced-guide.md#identity)
      4. [Arrays](doc/advanced-guide.md#arrays)
      5. [Optional](doc/advanced-guide.md#optional)
      6. [References](doc/advanced-guide.md#references)
      7. [Property Reference](doc/advanced-guide.md#property-reference)
    3. [Extending Alice](doc/advanced-guide.md#extending-alice)
      1. [Custom Flag](doc/advanced-guide.md#custom-flag)
      2. [Custom Instantiation](doc/advanced-guide.md#custom-instantiator)
      3. [Custom Accessor](doc/advanced-guide.md#custom-accessor)
  9. Third-party libraries
    1. Symfony
    2. Nette
    3. Zend Framework 2
    4. Framework Agnostic
  10. [Contribute](CONTRIBUTING.md#contribute)
    1. [Differences between 2.x and 3.x](CONTRIBUTING.md#differences-between-2x-and-3x)
    2. [Architecture](CONTRIBUTING.md#architecture)
      1. [FixtureBuilder](CONTRIBUTING.md#fixturebuilder)
      2. [Generator](CONTRIBUTING.md#generator)
    3. [Expression Language](CONTRIBUTING.md#expression-language)
    4. [Contributing](CONTRIBUTING.md#contributing)
      1. [Testing](CONTRIBUTING.md#testing)
      2. [Profiling](CONTRIBUTING.md#profiling)
  11. Backward Compatibility Promise (BCP)
  12. Upgrade
    1. [Breaking changes between Alice 2.x and 3.0](UPGRADE.md#breaking-changes-between-alice-2x-and-30)


This is installable via Composer as nelmio/alice:

composer require --dev nelmio/alice


Here is a complete example of entity declaration:

        username: '<username()>'
        fullname: '<firstName()> <lastName()>'
        birthDate: '<date_create()>'
        email: '<email()>'
        favoriteNumber: '50%? <numberBetween(1, 200)>'

        name: Admins
        owner: '@user1'
        members: '<numberBetween(1, 10)>x @user*'
        created: '<dateTimeBetween("-200 days", "now")>'
        updated: '<dateTimeBetween($created, "now")>'

You can then load them easily with:

$loader = new Nelmio\Alice\Loader\NativeLoader();
$objectSet = $loader->loadFile(__DIR__.'/fixtures.yml');

Or load an array right away:

$loader = new Nelmio\Alice\Loader\NativeLoader();
$objectSet = $loader->loadData([
    \Nelmio\Entity\User::class => [
        'user{1..10}' => [
            'username' => '<username()>',
            'fullname' => '<firstName()> <lastName()>',
            'birthDate' => '<date_create()>',
            'email' => '<email()>',
            'favoriteNumber' => '50%? <numberBetween(1, 200)>',
    \Nelmio\Entity\Group::class => [
        'group1' => [
            'name' => 'Admins',
            'owner' => '@user1',
            'members' => '<numberBetween(1, 10)>x @user*',
            'created' => '<dateTimeBetween("-200 days", "now")>',
            'updated' => '<dateTimeBetween($created, "now")>',

For more information, refer to the documentation.

Third-party libraries

Framework Agnostic




Zend Framework 2:


Check the [contribution guide](CONTRIBUTING.md).

Backward Compatibility Promise (BCP)

The policy is for the major part following the same as Symfony's one with a few changes or highlights:

  • Code marked with @private or @internal are excluded from the BCP
  • Nelmio\Alice\Loader\NativeLoader is excluded from the BCP: as it is the no DIC solution, registring a new service may require a new method, in which case your code may break if you have already declared that method. To avoid that, please beware of the naming of your methods to avoid any conflicts.


Check the [upgrade guide](UPGRADE.md).

*Note that all licence references and agreements mentioned in the Alice README section above are relevant to that project's source code only.