PHPackages                             api-skeletons/laravel-doctrine-data-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. [Database &amp; ORM](/categories/database)
4. /
5. api-skeletons/laravel-doctrine-data-fixtures

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

api-skeletons/laravel-doctrine-data-fixtures
============================================

Doctrine Data Fixtures for Laravel

1.0.3(1y ago)09301[1 PRs](https://github.com/API-Skeletons/laravel-doctrine-data-fixtures/pulls)MITPHPPHP ^8.0

Since Feb 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/API-Skeletons/laravel-doctrine-data-fixtures)[ Packagist](https://packagist.org/packages/api-skeletons/laravel-doctrine-data-fixtures)[ RSS](/packages/api-skeletons-laravel-doctrine-data-fixtures/feed)WikiDiscussions main Synced today

READMEChangelog (6)Dependencies (8)Versions (7)Used By (0)

Laravel Doctrine Data Fixtures
==============================

[](#laravel-doctrine-data-fixtures)

[![Continuous Integration](https://github.com/API-Skeletons/laravel-doctrine-data-fixtures/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/API-Skeletons/laravel-doctrine-data-fixtures/actions/workflows/continuous-integration.yml)[![Code Coverage](https://camo.githubusercontent.com/336e10240c56da40494bce16ff0477c0fcf25e950adb9a728b0ba2c8ea3d3bfb/68747470733a2f2f636f6465636f762e696f2f67682f4150492d536b656c65746f6e732f6c61726176656c2d646f637472696e652d646174612d66697874757265732f6272616e63682f6d61696e2f6772617068732f62616467652e737667)](https://codecov.io/gh/API-Skeletons/laravel-doctrine-data-fixtures/branch/main)[![PHP Version](https://camo.githubusercontent.com/d43f3018edfd35e43d9669f893ce52781d51f11ac9240420a3dce982b6ae8af1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302532622d626c7565)](https://img.shields.io/badge/PHP-8.0%2b-blue)[![Laravel Version](https://camo.githubusercontent.com/7330d8a5139fa5b0654b55716554c94de722670528ade3db570ad7e3e09c3156/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d382e782532622d726564)](https://img.shields.io/badge/Laravel-5.7%20to%208.x-red)[![Total Downloads](https://camo.githubusercontent.com/bc039678bdeccc56a2f58d0fae21c095544338c383e53d3424557f1acec43056/68747470733a2f2f706f7365722e707567782e6f72672f6170692d736b656c65746f6e732f6c61726176656c2d646f637472696e652d646174612d66697874757265732f646f776e6c6f616473)](//packagist.org/packages/api-skeletons/laravel-doctrine-data-fixtures)[![License](https://camo.githubusercontent.com/a0c86b2b675d781f4fa5b6db5c9cea555ab4c3fab9712e9bc188a13aa28b9855/68747470733a2f2f706f7365722e707567782e6f72672f6170692d736b656c65746f6e732f6c61726176656c2d646f637472696e652d646174612d66697874757265732f6c6963656e7365)](//packagist.org/packages/api-skeletons/laravel-doctrine-data-fixtures)

Laravel has built-in support for 'seed' data. In seed data, the classes are not namespaced and many developers treat seed data as a one-time import. Seed data often uses auto-increment primary keys. Perhaps these notes are what differentiates seed data from Fixtures.

In my fixtures I want static primary keys and I want to be able to re-run my fixtures at any time. I want the data my fixtures populate to be stored with my fixtures and I want to reference fixture values though class constants within my code.

For instance, to validate a user has an ACL role the code may read:

```
$acl->hasRole($user, 'admin');
```

but this use of strings in the code does not read well and may be error-prone. Instead of the above, I want my code to read

```
use App\ORM\Fixture\RoleFixture;

$acl->hasRole($user, RoleFixture::admin);
```

This pattern is not possible with seed data because seed data does not have namespaces. So, this repository exists not only as an alternative to Laravel seed data, but as a namespaced-integrated tool for static database data.

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

[](#installation)

Run the following to install this library using [Composer](https://getcomposer.org/):

```
composer require api-skeletons/laravel-doctrine-data-fixtures
```

A `doctrine-data-fixtures.php` configuration file is required. Publish the included config to your project:

```
php artisan vendor:publish --tag=config --provider="ApiSkeletons\Laravel\Doctrine\DataFixtures\ServiceProvider"
```

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

[](#configuration)

Doctrine MongoDB, ORM and PHPCR are supported. See the configuration file for details.

This example assumes `laravel-doctrine/orm` is installed and you'll be using fixtures for ORM data:

```
return [
    'default' => [  // This is the group name
        'entityManager' => EntityManager::class,
        'executor' => ORMExecutor::class,
        'purger' => ORMPurger::class,
        'fixtures' => [
            Fixture1::class,
            Fixture2::class,
        ],
    ],
];
```

### Fixture Groups

[](#fixture-groups)

Modeled from [api-skeletons/doctrine-data-fixture](https://github.com/API-Skeletons/doctrine-data-fixture)for Laminas, fixtures are organized into groups. This organization allows fixtures for specific modules, development faker data, different entity managers, and so on.

Use
---

[](#use)

### List Fixtures

[](#list-fixtures)

List all groups or list all fixtures for a group.

```
php artisan doctrine:data-fixtures:list []
```

The `` is optional.

### Executing a Fixture Group through Artisan command

[](#executing-a-fixture-group-through-artisan-command)

```
php artisan doctrine:data-fixtures:import  [--purge-with-truncate] [--do-not-append]
```

The `` is required.

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

Options:

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

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

Executing a Fixture Group from code
-----------------------------------

[](#executing-a-fixture-group-from-code)

For unit testing or other times you must run your fixtures from within code, follow this example:

```
use use Doctrine\Common\DataFixtures\Loader;

$config = config('doctrine-data-fixtures')[$groupName];

$objectManager = app($config['objectManager']);
$purger        = app($config['purger']);
$executorClass = $config['executor'];
$loader        = new Loader();

foreach ($config['fixtures'] as $fixture) {
    $loader->addFixture($fixture);
}

$executor = new $executorClass($objectManager, $purger);
$executor->execute($loader->getFixtures());
```

Doctrine data-fixtures
----------------------

[](#doctrine-data-fixtures)

Be sure to read the documentation on the parent library [doctrine/data-fixtures](https://github.com/doctrine/data-fixtures)

###  Health Score

31

—

LowBetter than 71% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Recently: every ~199 days

Total

6

Last Release

711d ago

Major Versions

0.1.1 → 1.0.02022-02-05

### 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 (23 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[summerblue/administrator

A database interface package for Laravel, modified!

29329.8k1](/packages/summerblue-administrator)[sleeping-owl/with-join

Package to convert Eloquent BelongsTo subqueries into one query with left join.

9288.2k8](/packages/sleeping-owl-with-join)[rorecek/laravel-ulid

Laravel package for ULID (Universally Unique Lexicographically Sortable Identifier)

52159.0k1](/packages/rorecek-laravel-ulid)[adobrovolsky97/laravel-repository-service-pattern

Laravel 5|6|7|8|9|10 - Repository - Service Pattern

275.3k](/packages/adobrovolsky97-laravel-repository-service-pattern)

PHPackages © 2026

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