Expressive fixtures generator

v3.0.0-beta.0 2016-09-14 13:19 UTC


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.

Warning: this doc is behind updated for alice 3.0. If you want to check the documentation for 2.x, head this way.

Table of Contents

  1. Installation
  2. Example
  3. Getting Started
    1. Basic Usage
    2. Framework integration
      1. Symfony
  4. Complete Reference
    1. Creating Fixtures
      1. YAML
      2. PHP
    2. Fixture Ranges
    3. Calling Methods
    4. Specifying Constructor Arguments
    5. Optional Data
    6. Handling Unique Constraints
  5. Handling Relations
    1. References
    2. Multiple References
    3. Self reference
    4. Passing references to providers
  6. Keep Your Fixtures Dry
    1. Fixture Inheritance
    2. Including files
    3. Variables
    4. Parameters
  7. Customize Data Generation
    1. Faker Data
    2. Localized Fake Data TODO: port that change to v2
    3. Default Providers
      1. Identity
    4. Reuse generated data using objects value
    5. Custom Faker Data Providers
  8. Third-party libraries
  9. Contribute
  10. Upgrade
  11. License

Other references:


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()>'
        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()>',
            '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


Check the contribution guide.


Check the upgrade guide.


Released under the MIT License.