PHPackages                             arnolem/magic-fixtures - 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. arnolem/magic-fixtures

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

arnolem/magic-fixtures
======================

Easy Fixtures generator

2.2.0(2y ago)121MITPHPPHP ^8.2

Since Aug 2Pushed 2y ago1 watchersCompare

[ Source](https://github.com/arnolem/magic-fixtures)[ Packagist](https://packagist.org/packages/arnolem/magic-fixtures)[ Docs](https://www.wixiweb.fr)[ RSS](/packages/arnolem-magic-fixtures/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (2)Versions (6)Used By (0)

Magic Fixtures
==============

[](#magic-fixtures)

Magic Fixtures allows you to quickly and easily create fixtures to simplify development and testing.

Installing
----------

[](#installing)

[PHP](https://php.net) 8.2+ and [Composer](https://getcomposer.org) are required.

```
composer req --dev arnolem/magic-fixtures
```

Main features
-------------

[](#main-features)

- Fixtures are native PHP classes.
- Fixtures are automatically loaded from a directory.
- Fixtures are compatible with `Psr\Container\ContainerInterface` to integrate with all frameworks.
- It manages the dependencies between fixtures using the needs() method.
- The created objects can be stored for use in other fixtures.
- The objects can be retrieved by identifier, but also by class, by tag, or randomly.
- Randomly retrieve objects that match a tag.
- Integration of Faker to generate fake data.

Usage
-----

[](#usage)

### Installation

[](#installation)

Installation example for Symfony:

```
namespace Tests\Account;

use Arnolem\MagicFixtures\MagicFixtures;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

class AccountCase extends KernelTestCase
{

    /**
     * @throws DirectoryNotFoundException
     */
    public static function setUpBeforeClass(): void
    {
        // Boot Symfony Kernel
        self::bootKernel();

        // Provide Symfony Container to Magic Fixtures
        $magicFixtures = new MagicFixtures(self::getContainer());

        // Load all Fixtures form "/Tests/Fixtures/*"
        $magicFixtures->loadFromDirectory(__DIR__ . '/Fixture');

        // Executes Fixtures
        $magicFixtures->execute();
    }

    public function testTrue(): void
    {
        $this->assertTrue(true);
    }

}
```

### Your first fixture

[](#your-first-fixture)

```
namespace Tests\Fixture;

use App\Domain\Account;
use App\Domain\Company;
use App\Infrastructure\AccountPersister;
use Arnolem\MagicFixtures\Fixture;

readonly class AccountFixture extends Fixture
{

    public function __construct()
    {
        $this->accountPersister = $this->getService(AccountPersister::class);
    }

    public function execute(): void
    {
        $account = new Account(
            firstname: 'Arnaud',
            name: 'Lemercier',
            company: $this->getRandomReference(Company::class);
        );

        $this->accountPersister->save($account);
    }

    public function needs(): array
    {
        return [
            Company::class
        ];
    }
}
```

Another depends Fixture

```
namespace Tests\Fixture;

use App\Domain\Company;
use App\Infrastructure\CompanyPersister;
use Arnolem\MagicFixtures\Fixture;

readonly class CompanyFixture extends Fixture
{

    public function __construct()
    {
        $this->companyPersister = $this->getService(CompanyPersister::class);
    }

    public function execute(): void
    {

        // Create a default and activated company
        $company = new Company(
            id: 0
            name: 'Wixiweb',
            isActivate: true,
        );

        $this->companyPersister->save($company);
        $this->addReference($company, $company->getId(), ['activate', 'default']);

        // Create others 10 inactivates companies
        for ($idCompany = 1; $idCompany faker->company(),
                isActivate: false,
            );

            $this->companyPersister->save($company);
            $this->addReference($company, $company->getId();
        }

    }
}
```

Credits
-------

[](#credits)

- Arnaud Lemercier is based on [Wixiweb](https://wixiweb.fr).

License
-------

[](#license)

Magic Fixtures is licensed under [The MIT License (MIT)](LICENSE).

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~4 days

Total

4

Last Release

1052d ago

Major Versions

1.0.0 → 2.0.02023-08-03

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2263147?v=4)[Wixiweb](/maintainers/wixiweb)[@wixiweb](https://github.com/wixiweb)

![](https://avatars.githubusercontent.com/u/2263103?v=4)[Arnaud Lemercier](/maintainers/arnolem)[@arnolem](https://github.com/arnolem)

---

Top Contributors

[![arnolem](https://avatars.githubusercontent.com/u/2263103?v=4)](https://github.com/arnolem "arnolem (11 commits)")

---

Tags

testFixturefakerdatadatabaseenvironmentenv

### Embed Badge

![Health badge](/badges/arnolem-magic-fixtures/health.svg)

```
[![Health](https://phpackages.com/badges/arnolem-magic-fixtures/health.svg)](https://phpackages.com/packages/arnolem-magic-fixtures)
```

###  Alternatives

[nelmio/alice

Expressive fixtures generator

2.5k45.2M165](/packages/nelmio-alice)[zenstruck/foundry

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

79613.7M146](/packages/zenstruck-foundry)[testo/testo

A lightweight PHP testing framework.

1959.3k53](/packages/testo-testo)[fakerino/fakerino

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

12114.8k5](/packages/fakerino-fakerino)[trappar/alice-generator

Automatically generates alice fixture based on a set of objects

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

Symfony bundle for generating Alice fixtures from Doctrine entities

45169.7k1](/packages/trappar-alice-generator-bundle)

PHPackages © 2026

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