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

Abandoned → [api-skeletons/doctrine-data-fixture](/?search=api-skeletons%2Fdoctrine-data-fixture)Library[Database &amp; ORM](/categories/database)

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

Doctrine Data Fixture Console Route with Service Manager configured Fixtures

5.0.9(7y ago)922.9k↓33.3%4[1 issues](https://github.com/API-Skeletons/zf-doctrine-data-fixture/issues)1MITPHPPHP ^7.1.0

Since Jan 15Pushed 6y ago1 watchersCompare

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

READMEChangelog (10)Dependencies (13)Versions (31)Used By (1)

ZF Doctrine Data Fixture
========================

[](#zf-doctrine-data-fixture)

[![Build status](https://camo.githubusercontent.com/9362d4b9eaebd2aecbb7d4ecbb6d0d755585d827bc4f69fcbb605746e3f35ee7/68747470733a2f2f6170692e7472617669732d63692e6f72672f4150492d536b656c65746f6e732f7a662d646f637472696e652d646174612d666978747572652e737667)](http://travis-ci.org/API-Skeletons/zf-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/7cbf6271f7d2ad360e0899c10ce3776aa2fae9c9f6305e1c9f0f4c129c335a4f/68747470733a2f2f706f7365722e707567782e6f72672f4150492d536b656c65746f6e732f7a662d646f637472696e652d646174612d666978747572652f646f776e6c6f616473)](https://packagist.org/packages/API-Skeletons/zf-doctrine-data-fixture)

This provides command line support for Doctrine Fixtures in Zend Framework 2. 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 Zend Service Manager configurable on a per-group basis.

Releases
--------

[](#releases)

The 4.x release tags support PHP 5.6 and 7.0.

The 5.x release tags support PHP 7.1 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/zf-doctrine-data-fixture ^2.0
```

Add this module to your application's configuration:

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

> ### zf-component-installer
>
> [](#zf-component-installer)
>
> If you use [zf-component-installer](https://github.com/zendframework/zf-component-installer), that plugin will install zf-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',
                '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 [Zend ServiceManager](http://framework.zend.com/manual/current/en/in-depth-guide/services-and-servicemanager.html) configuration. This allows complete dependency injection control of your fixtures.

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.

The default was to not append and this was constantly overridden with --append. Append is now to 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 ZF\Doctrine\DataFixture\Loader;

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

$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.

History
-------

[](#history)

Version 1.0 of this module grouped groups by partial object manager alias. This limited grouping of 3rd party fixtures and the flexibility of using ODM.

This module is a near complete rewrite of [hounddog/doctrine-data-fixture-module](https://github.com/Hounddog/DoctrineDataFixtureModule). All the patterns have changed and the code was reduced. That module served me and the community well for a long time.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 54.4% 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 ~79 days

Recently: every ~102 days

Total

29

Last Release

2657d ago

Major Versions

1.0.6 → 2.0.02016-09-26

2.0.0 → 3.0.02016-12-23

3.0.2 → 4.0.02017-06-23

4.0.2 → 5.0.02017-09-06

4.0.3 → 5.0.12017-10-19

PHP version history (4 changes)0.0.1PHP &gt;=5.3.3

1.0.2PHP ~5.6 || ^7.0

5.0.0PHP ^7.1

5.0.8PHP ^7.1.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 (43 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)")[![caferrari](https://avatars.githubusercontent.com/u/89180?v=4)](https://github.com/caferrari "caferrari (2 commits)")[![maxnuf](https://avatars.githubusercontent.com/u/1273539?v=4)](https://github.com/maxnuf "maxnuf (1 commits)")[![thomaroger](https://avatars.githubusercontent.com/u/1062137?v=4)](https://github.com/thomaroger "thomaroger (1 commits)")[![internalsystemerror](https://avatars.githubusercontent.com/u/1626298?v=4)](https://github.com/internalsystemerror "internalsystemerror (1 commits)")[![adamlundrigan](https://avatars.githubusercontent.com/u/527329?v=4)](https://github.com/adamlundrigan "adamlundrigan (1 commits)")[![argentinaluiz](https://avatars.githubusercontent.com/u/4926329?v=4)](https://github.com/argentinaluiz "argentinaluiz (1 commits)")[![ackimwilliams](https://avatars.githubusercontent.com/u/4093815?v=4)](https://github.com/ackimwilliams "ackimwilliams (1 commits)")

---

Tags

doctrinedata-fixture

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[hounddog/doctrine-data-fixture-module

Zend Framework 2 Module that provides Doctrine Data-Fixture functionality

37335.4k9](/packages/hounddog-doctrine-data-fixture-module)[mamuz/mamuz-blog

Provides blog feature for ZF2 with Doctrine

101.1k1](/packages/mamuz-mamuz-blog)

PHPackages © 2026

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