PHPackages                             api-skeletons/doctrine-data-fixture - 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. api-skeletons/doctrine-data-fixture

ActiveLibrary[Database &amp; ORM](/categories/database)

api-skeletons/doctrine-data-fixture
===================================

Doctrine Data Fixtures with Grouping for Laminas

6.0.8(2y ago)038.8k—8.6%5[1 PRs](https://github.com/API-Skeletons/doctrine-data-fixture/pulls)MITPHPPHP ^7.2.0 || ~8.0CI failing

Since Mar 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/API-Skeletons/doctrine-data-fixture)[ Packagist](https://packagist.org/packages/api-skeletons/doctrine-data-fixture)[ Docs](https://apiskeletons.com)[ RSS](/packages/api-skeletons-doctrine-data-fixture/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (13)Versions (10)Used By (0)

Doctrine Data Fixtures with Grouping for Laminas
================================================

[](#doctrine-data-fixtures-with-grouping-for-laminas)

[![Build status](https://camo.githubusercontent.com/03aba052781d44eb54f35d9d35202ac4bf8397ab8f4fa77a4c6291790a20d78a/68747470733a2f2f6170692e7472617669732d63692e6f72672f4150492d536b656c65746f6e732f646f637472696e652d646174612d666978747572652e737667)](http://travis-ci.org/API-Skeletons/doctrine-data-fixture)[![Gitter](https://camo.githubusercontent.com/c45f0485e89d3cd41f666d7d4bb5875cb59836555e05b6b11f77ed223eb64c0c/68747470733a2f2f6261646765732e6769747465722e696d2f6170692d736b656c65746f6e732f6f70656e2d736f757263652e737667)](https://gitter.im/api-skeletons/open-source)[![Patreon](https://camo.githubusercontent.com/f9e075baad95563481d35174d43ef50757281abb6bc795d0f473fad452afa030/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617472656f6e2d646f6e6174652d79656c6c6f772e737667)](https://www.patreon.com/apiskeletons)[![Total Downloads](https://camo.githubusercontent.com/5c81fee44666c16affb0359dbf2c6b92fb2cd71eb6f07bd844c5f84ab63c1d6b/68747470733a2f2f706f7365722e707567782e6f72672f4150492d536b656c65746f6e732f646f637472696e652d646174612d666978747572652f646f776e6c6f616473)](https://packagist.org/packages/API-Skeletons/doctrine-data-fixture)

This provides command line support for Doctrine Fixtures in Laminas. Often projects will have multiple sets of fixtures for different object managers or modules such as from a 3rd party API. When this is the case a tool which can run fixtures in groups is needed. Additionally dependency injection must be available to the fixtures. To accomplish these needs this module uses a Service Manager configurable on a per-group basis.

Releases
--------

[](#releases)

The 6.x release tags support PHP 7.2 and above.

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

[](#installation)

Installation of this module uses composer. For composer documentation, please refer to [getcomposer.org](http://getcomposer.org/).

```
$ composer require api-skeletons/doctrine-data-fixture
```

Add this module to your application's configuration:

```
'modules' => [
   ...
   'ApiSkeletons\Doctrine\DataFixture',
],
```

> ### laminas-component-installer
>
> [](#laminas-component-installer)
>
> If you use [laminas-component-installer](https://github.com/laminas/laminas-component-installer), that plugin will install doctrine-data-fixture as a module for you.

Configuration
-------------

[](#configuration)

This module builds on top of Doctrine configuration. The configuration in a module which implements fixtures is:

```
return [
    'doctrine' => [
        'fixture' => [
            'group1' => [
                'object_manager' => 'doctrine.entitymanager.orm_default',
                'executor' => Executor::class,
                'purger' => Purger::class,
                'invokables' => [
                    'ModuleName\Fixture\FixtureOne' => 'ModuleName\Fixture\FixtureOne',
                ],
                'factories' => [
                    'ModuleName\Fixture\FixtureTwo' => 'ModuleName\Fixture\FixtureTwoFactory',
                ]
            ],
            'group2' => [
                'object_manager' => 'doctrine.entitymanager.orm_zf_doctrine_audit',
                ...
            ],
        ],
    ],
];
```

Each group is a [Laminas ServiceManager](https://docs.laminas.dev/laminas-servicemanager/) configuration. This allows complete dependency injection control of your fixtures.

The 'executor' and 'purger' keys are optional and allow for custom classes for these functions. If omitted the Doctrine ORM classes will be used.

Listing Fixtures
----------------

[](#listing-fixtures)

```
index.php data-fixture:list []
```

List all object managers and their groups, list all groups for a given object manager, or specify object manager and group to list all fixtures for a group.

Executing Fixtures from Command Line
------------------------------------

[](#executing-fixtures-from-command-line)

```
index.php data-fixture:import  [--purge-with-truncate] [--do-not-append]
```

The `` is required.

Append is the default option. This is inversed with the new --do-not-append

Options:

`--purge-with-truncate` if specified will purge the object manager's tables before running fixtures.

`--do-not-append` will delete all data in the database before running fixtures.

Executing Fixtures from Code
----------------------------

[](#executing-fixtures-from-code)

For unit testing or other times you must run your fixtures from within code you must fetch the `DataFixtureManager` with `build` and pass the group name to the service manager then load the fixtures into the `Loader` manually.

```
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use ApiSkeletons\Doctrine\DataFixture\Loader;

// Run audit fixtures
$dataFixtureManager = $application->getServiceManager()
    ->build('ApiSkeletons\Doctrine\DataFixture\DataFixtureManager', ['group' => 'group-name']);

$loader = new Loader($dataFixtureManager);
$purger = new ORMPurger();
$executor = new ORMExecutor($auditEntityManager, $purger);

foreach ($dataFixtureManager->getAll() as $fixture) {
    $loader->addFixture($fixture);
}

$executor->execute($loader->getFixtures(), true);
```

Getting Help
------------

[](#getting-help)

```
index.php data-fixture:help
```

Important Notes
---------------

[](#important-notes)

- You can only run one group at a time from the command line. If you need to run more create a script to run them in sequence.
- The ServiceManager is injected into each DataFixtureManager at getServiceLocator() so you can use instantiators which run from that level. This makes the DataFixtureManager work like a plugin manager defined with `$serviceListener->addServiceManager()`.
- You cannot use abstract factories. Each fixture must be individually configured.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 62.9% 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 ~168 days

Recently: every ~269 days

Total

9

Last Release

917d ago

PHP version history (2 changes)6.0.0PHP ^7.2.0

6.0.7PHP ^7.2.0 || ~8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/49dd7d9dba889ac674b0da447d9c1e69d1128dc3ccbaef98ba83d6ee519fc2d6?d=identicon)[tom\_anderson](/maintainers/tom_anderson)

---

Top Contributors

[![TomHAnderson](https://avatars.githubusercontent.com/u/493920?v=4)](https://github.com/TomHAnderson "TomHAnderson (66 commits)")[![Hounddog](https://avatars.githubusercontent.com/u/1188248?v=4)](https://github.com/Hounddog "Hounddog (14 commits)")[![Ocramius](https://avatars.githubusercontent.com/u/154256?v=4)](https://github.com/Ocramius "Ocramius (14 commits)")[![BrunoSpy](https://avatars.githubusercontent.com/u/954222?v=4)](https://github.com/BrunoSpy "BrunoSpy (2 commits)")[![caferrari](https://avatars.githubusercontent.com/u/89180?v=4)](https://github.com/caferrari "caferrari (2 commits)")[![gulerGTS](https://avatars.githubusercontent.com/u/159452110?v=4)](https://github.com/gulerGTS "gulerGTS (1 commits)")[![ackimwilliams](https://avatars.githubusercontent.com/u/4093815?v=4)](https://github.com/ackimwilliams "ackimwilliams (1 commits)")[![internalsystemerror](https://avatars.githubusercontent.com/u/1626298?v=4)](https://github.com/internalsystemerror "internalsystemerror (1 commits)")[![maxnuf](https://avatars.githubusercontent.com/u/1273539?v=4)](https://github.com/maxnuf "maxnuf (1 commits)")[![adamlundrigan](https://avatars.githubusercontent.com/u/527329?v=4)](https://github.com/adamlundrigan "adamlundrigan (1 commits)")[![thomaroger](https://avatars.githubusercontent.com/u/1062137?v=4)](https://github.com/thomaroger "thomaroger (1 commits)")[![argentinaluiz](https://avatars.githubusercontent.com/u/4926329?v=4)](https://github.com/argentinaluiz "argentinaluiz (1 commits)")

---

Tags

laminasdoctrinedata-fixture

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/api-skeletons-doctrine-data-fixture/health.svg)

```
[![Health](https://phpackages.com/badges/api-skeletons-doctrine-data-fixture/health.svg)](https://phpackages.com/packages/api-skeletons-doctrine-data-fixture)
```

###  Alternatives

[doctrine/doctrine-orm-module

Laminas Module that provides Doctrine ORM functionality

4407.3M293](/packages/doctrine-doctrine-orm-module)[doctrine/doctrine-module

Laminas Module that provides Doctrine basic functionality required for ORM and ODM modules

3957.9M116](/packages/doctrine-doctrine-module)[doctrine/doctrine-mongo-odm-module

Laminas Module which provides Doctrine MongoDB ODM functionality

86676.6k35](/packages/doctrine-doctrine-mongo-odm-module)[hounddog/doctrine-data-fixture-module

Zend Framework 2 Module that provides Doctrine Data-Fixture functionality

37335.4k9](/packages/hounddog-doctrine-data-fixture-module)[zfc-datagrid/zfc-datagrid

Laminas Module that provides a datagrid for different datasources and output formats

1223.2k](/packages/zfc-datagrid-zfc-datagrid)

PHPackages © 2026

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