PHPackages                             nelmio/alice - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. nelmio/alice

ActiveLibrary[Testing &amp; Quality](/categories/testing)

nelmio/alice
============

Expressive fixtures generator

3.17.0(2mo ago)2.5k43.4M—5.3%330[47 issues](https://github.com/nelmio/alice/issues)[2 PRs](https://github.com/nelmio/alice/pulls)20MITPHPPHP ^8.2CI passing

Since Nov 22Pushed 1mo ago45 watchersCompare

[ Source](https://github.com/nelmio/alice)[ Packagist](https://packagist.org/packages/nelmio/alice)[ GitHub Sponsors](https://github.com/theofidry)[ RSS](/packages/nelmio-alice/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (15)Versions (94)Used By (20)

 [![](doc/img/nelmio.png)](doc/img/nelmio.png)

Alice - Expressive fixtures generator
=====================================

[](#alice---expressive-fixtures-generator)

[![Package version](https://camo.githubusercontent.com/d0f6232c91d084b088b0ab28f15c25745df2acf4e3819202552d9a417d105e40/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e656c6d696f2f616c6963652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nelmio/alice)[![Build Status](https://github.com/nelmio/alice/workflows/CI/badge.svg?branch=master)](https://github.com/nelmio/alice/actions)[![Slack](https://camo.githubusercontent.com/a417e9b124e072be924465ed963504c2acc9d5f643b71ed4fd4d8378eb654c73/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736c61636b2d253233616c6963652d2d66697874757265732d7265642e7376673f7374796c653d666c61742d737175617265)](https://symfony.com/slack-invite)[![License](https://camo.githubusercontent.com/10e85a5778fe7601504a17ecd18dfa7097f473186b0f947bc10db2d3e4f530e4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d7265642e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Relying on [FakerPHP/Faker](https://github.com/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](https://github.com/nelmio/alice/tree/2.x)**.

**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
-----------------

[](#table-of-contents)

1. [Installation](#installation)
2. [Example](#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](#third-party-libraries)
    1. [Symfony](#symfony)
    2. [Nette](#nette)
    3. [Zend Framework 2](#zend-framework-2)
    4. [Framework Agnostic](#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)](#backward-compatibility-promise-bcp)
12. [Upgrade](#upgrade)
    1. [Breaking changes between Alice 2.x and 3.0](UPGRADE.md#breaking-changes-between-alice-2x-and-30)

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

[](#installation)

This is installable via [Composer](https://getcomposer.org/) as [nelmio/alice](https://packagist.org/packages/nelmio/alice):

```
composer require --dev nelmio/alice

```

Example
-------

[](#example)

Here is a complete example of entity declaration:

```
Nelmio\Entity\User:
    user{1..10}:
        username: ''
        fullname: ' '
        birthDate: ''
        email: ''
        favoriteNumber: '50%? '

Nelmio\Entity\Group:
    group1:
        name: Admins
        owner: '@user1'
        members: 'x @user*'
        created: ''
        updated: ''
```

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' => '',
            'fullname' => ' ',
            'birthDate' => '',
            'email' => '',
            'favoriteNumber' => '50%? ',
        ],
    ],
    \Nelmio\Entity\Group::class => [
        'group1' => [
            'name' => 'Admins',
            'owner' => '@user1',
            'members' => 'x @user*',
            'created' => '',
            'updated' => '',
        ],
    ],
]);
```

For more information, refer to [the documentation](#table-of-contents).

Third-party libraries
---------------------

[](#third-party-libraries)

### Framework Agnostic

[](#framework-agnostic)

- [theofidry/AliceDataFixtures](https://github.com/theofidry/AliceDataFixtures)
- [trappar/AliceGenerator](https://github.com/trappar/AliceGenerator)

### Symfony

[](#symfony)

- [hautelook/AliceBundle](https://github.com/theofidry/AliceBundle)

### Nette

[](#nette)

- [Zenify/DoctrineFixtures](https://github.com/Zenify/DoctrineFixtures)

### WordPress

[](#wordpress)

- [rmp-up/wp-fixtures](https://github.com/rmp-up/wp-fixtures)

### Zend Framework 2:

[](#zend-framework-2)

- [ma-si/aist-alice-fixtures](https://github.com/ma-si/aist-alice-fixtures)

Contribute
----------

[](#contribute)

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

Backward Compatibility Promise (BCP)
------------------------------------

[](#backward-compatibility-promise-bcp)

The policy is for the major part following the same as [Symfony's one](https://symfony.com/doc/current/contributing/code/bc.html) 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.

Upgrade
-------

[](#upgrade)

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

###  Health Score

81

—

ExcellentBetter than 100% of packages

Maintenance87

Actively maintained with recent releases

Popularity78

Solid adoption and visibility

Community54

Growing community involvement

Maturity92

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~56 days

Recently: every ~91 days

Total

87

Last Release

83d ago

Major Versions

v2.3.1 → v3.0.0-beta.52017-04-11

v2.3.3 → v3.1.02017-10-22

v2.3.4 → v3.1.22017-11-17

v2.3.5 → v3.4.02018-05-29

v2.3.6 → v3.8.02021-01-13

PHP version history (13 changes)1.0.0PHP &gt;=5.3

2.0.0PHP &gt;=5.4

2.2.0PHP ^5.6||^7.0

v3.0.0-beta.0PHP ^7.0

v3.0.0-beta.4PHP 7.0 - 7.1

v3.2.0PHP ^7.1

v3.7.0PHP ^7.3

2.x-devPHP ^5.6||^7.0||^8.0

v3.8.0PHP ^7.3 || ^8.0

v3.9.0PHP ^7.4 || ^8.0

v3.10.0PHP ^8.0

v3.11.0PHP ^8.1

3.15.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/b69782e1d7f426ef78f61d159c466a536372eff931f13981ac578fa3f4649352?d=identicon)[Seldaek](/maintainers/Seldaek)

![](https://www.gravatar.com/avatar/6fbf458a1f05f8ac5a3c8f6c5426abe81084b7077b24955747b09c35f6c983be?d=identicon)[theofidry](/maintainers/theofidry)

---

Top Contributors

[![theofidry](https://avatars.githubusercontent.com/u/5175937?v=4)](https://github.com/theofidry "theofidry (471 commits)")[![Seldaek](https://avatars.githubusercontent.com/u/183678?v=4)](https://github.com/Seldaek "Seldaek (185 commits)")[![tshelburne](https://avatars.githubusercontent.com/u/1202267?v=4)](https://github.com/tshelburne "tshelburne (145 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (92 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (13 commits)")[![munkie](https://avatars.githubusercontent.com/u/102297?v=4)](https://github.com/munkie "munkie (11 commits)")[![jubianchi](https://avatars.githubusercontent.com/u/327237?v=4)](https://github.com/jubianchi "jubianchi (8 commits)")[![Yozhef](https://avatars.githubusercontent.com/u/8971757?v=4)](https://github.com/Yozhef "Yozhef (6 commits)")[![reinfi](https://avatars.githubusercontent.com/u/9324423?v=4)](https://github.com/reinfi "reinfi (6 commits)")[![enumag](https://avatars.githubusercontent.com/u/539462?v=4)](https://github.com/enumag "enumag (5 commits)")[![ogizanagi](https://avatars.githubusercontent.com/u/2211145?v=4)](https://github.com/ogizanagi "ogizanagi (5 commits)")[![addfs](https://avatars.githubusercontent.com/u/184040?v=4)](https://github.com/addfs "addfs (5 commits)")[![soullivaneuh](https://avatars.githubusercontent.com/u/1698357?v=4)](https://github.com/soullivaneuh "soullivaneuh (5 commits)")[![alekitto](https://avatars.githubusercontent.com/u/1257206?v=4)](https://github.com/alekitto "alekitto (5 commits)")[![kalifg](https://avatars.githubusercontent.com/u/487194?v=4)](https://github.com/kalifg "kalifg (4 commits)")[![baldurrensch](https://avatars.githubusercontent.com/u/871417?v=4)](https://github.com/baldurrensch "baldurrensch (4 commits)")[![Markcial](https://avatars.githubusercontent.com/u/208523?v=4)](https://github.com/Markcial "Markcial (3 commits)")[![benji07](https://avatars.githubusercontent.com/u/166890?v=4)](https://github.com/benji07 "benji07 (3 commits)")[![docteurklein](https://avatars.githubusercontent.com/u/109846?v=4)](https://github.com/docteurklein "docteurklein (3 commits)")[![grobx](https://avatars.githubusercontent.com/u/3105723?v=4)](https://github.com/grobx "grobx (3 commits)")

---

Tags

aliceexpression-languagefakerfixturefixturesmanage-fixturesphpsymfonysymfony-bundletestFixturefakerdata

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nelmio-alice/health.svg)

```
[![Health](https://phpackages.com/badges/nelmio-alice/health.svg)](https://phpackages.com/packages/nelmio-alice)
```

###  Alternatives

[zenstruck/foundry

A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.

78311.9M97](/packages/zenstruck-foundry)[nyholm/nsa

See everything and do whatever you want. No privacy rule will stop us. Used in tests, debugging and fixtures to access properties and methods.

2286.0M79](/packages/nyholm-nsa)[trappar/alice-generator

Automatically generates alice fixture based on a set of objects

52185.4k1](/packages/trappar-alice-generator)[trappar/alice-generator-bundle

Symfony bundle for generating Alice fixtures from Doctrine entities

45169.6k1](/packages/trappar-alice-generator-bundle)[fakerino/fakerino

Faker framework, for generate every kind of fake data for test, database seed, mock responses, other

12214.8k5](/packages/fakerino-fakerino)[niklongstone/regex-reverse

Regular Expression reverter, generates a string from a provided regular expression

105150.4k4](/packages/niklongstone-regex-reverse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
