PHPackages                             expio/neo4j-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. expio/neo4j-data-fixtures

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

expio/neo4j-data-fixtures
=========================

Data Fixtures for Neo4j OGM, based on Doctrine Data Fixtures

v1.0.0-ALPHA3(13y ago)11731MITPHPPHP &gt;=5.3.2

Since Jan 25Pushed 12y ago1 watchersCompare

[ Source](https://github.com/sgarner/neo4j-data-fixtures)[ Packagist](https://packagist.org/packages/expio/neo4j-data-fixtures)[ Docs](http://www.doctrine-project.org)[ RSS](/packages/expio-neo4j-data-fixtures/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (3)Used By (0)

Neo4j Data Fixtures Extension
=============================

[](#neo4j-data-fixtures-extension)

This extension aims to provide a simple way to manage and execute the loading of data fixtures for the Neo4j OGM. You can write fixture classes by implementing the Expio\\Common\\Neo4jDataFixtures\\FixtureInterface interface:

```
namespace MyDataFixtures;

use Kwattro\Neo4j\GraphManager;
use Expio\Common\Neo4jDataFixtures\FixtureInterface;

class LoadUserData implements FixtureInterface
{
    public function load(GraphManager $manager)
    {
        $user = new User();
        $user->setUsername('jwage');
        $user->setPassword('test');

        $manager->persist($user);
        $manager->flush();
    }
}

```

Now you can begin adding the fixtures to a loader instance:

```
use Expio\Common\Neo4jDataFixtures\Loader;
use MyDataFixtures\LoadUserData;

$loader = new Loader();
$loader->addFixture(new LoadUserData);

```

You can load a set of fixtures from a directory as well:

```
$loader->loadFromDirectory('/path/to/MyDataFixtures');

```

You can get the added fixtures using the getFixtures() method:

```
$fixtures = $loader->getFixtures();

```

Now you can easily execute the fixtures:

```
use Expio\Common\Neo4jDataFixtures\Executor\OGMExecutor;
use Expio\Common\Neo4jDataFixtures\Purger\OGMPurger;

$purger = new OGMPurger();
$executor = new OGMExecutor($em, $purger);
$executor->execute($loader->getFixtures());

```

If you want to append the fixtures instead of purging before loading then pass true to the 2nd argument of execute:

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

```

Sharing objects between fixtures
--------------------------------

[](#sharing-objects-between-fixtures)

In case if fixture objects have relations to other fixtures, it is now possible to easily add a reference to that object by name and later reference it to form a relation. Here is an example fixtures for **Role** and **User** relation

```
namespace MyDataFixtures;

use Expio\Common\Neo4jDataFixtures\AbstractFixture;
use HireVoice\Neo4j\EntityManager;

class LoadUserRoleData extends AbstractFixture
{
    public function load(ObjectManager $manager)
    {
        $adminRole = new Role();
        $adminRole->setName('admin');

        $anonymousRole = new Role;
        $anonymousRole->setName('anonymous');

        $manager->persist($adminRole);
        $manager->persist($anonymousRole);
        $manager->flush();

        // store reference to admin role for User relation to Role
        $this->addReference('admin-role', $adminRole);
    }
}

```

And the **User** data loading fixture:

```
namespace MyDataFixtures;

use Expio\Common\Neo4jDataFixtures\AbstractFixture;
use HireVoice\Neo4j\EntityManager;

class LoadUserData extends AbstractFixture
{
    public function load(ObjectManager $manager)
    {
        $user = new User();
        $user->setUsername('jwage');
        $user->setPassword('test');
        $user->setRole(
            $this->getReference('admin-role') // load the stored reference
        );

        $manager->persist($user);
        $manager->flush();

        // store reference of admin-user for other Fixtures
        $this->addReference('admin-user', $user);
    }
}

```

Fixture ordering
----------------

[](#fixture-ordering)

**Notice** that the fixture loading order is important! To handle it manually implement one of the following interfaces:

### OrderedFixtureInterface

[](#orderedfixtureinterface)

Set the order manually:

```
namespace MyDataFixtures;

use Expio\Common\Neo4jDataFixtures\AbstractFixture;
use Expio\Common\Neo4jDataFixtures\OrderedFixtureInterface;
use HireVoice\Neo4j\EntityManager;

class MyFixture extends AbstractFixture implements OrderedFixtureInterface
{
    public function load(ObjectManager $manager)
    {}

    public function getOrder()
    {
        return 10; // number in which order to load fixtures
    }
}

```

### DependentFixtureInterface

[](#dependentfixtureinterface)

Provide an array of fixture class names:

```
namespace MyDataFixtures;

use Expio\Common\Neo4jDataFixtures\AbstractFixture;
use Expio\Common\Neo4jDataFixtures\DependentFixtureInterface;
use HireVoice\Neo4j\EntityManager;

class MyFixture extends AbstractFixture implements DependentFixtureInterface
{
    public function load(ObjectManager $manager)
    {}

    public function getDependencies()
    {
        return array('MyDataFixtures\MyOtherFixture'); // fixture classes fixture is dependent on
    }
}

class MyOtherFixture extends AbstractFixture
{
    public function load(ObjectManager $manager)
    {}
}

```

**Notice** the ordering is relevant to Loader class.

Running the tests:
------------------

[](#running-the-tests)

PHPUnit 3.5 or newer together with Mock\_Object package is required. To setup and run tests follow these steps:

- go to the root directory of data-fixtures
- run: **git submodule init**
- run: **git submodule update**
- copy the phpunit config **cp phpunit.xml.dist phpunit.xml**
- run: **phpunit**

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor4

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

Total

2

Last Release

5032d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/904004?v=4)[Simon Garner](/maintainers/sgarner)[@sgarner](https://github.com/sgarner)

---

Top Contributors

[![beberlei](https://avatars.githubusercontent.com/u/26936?v=4)](https://github.com/beberlei "beberlei (21 commits)")[![guilhermeblanco](https://avatars.githubusercontent.com/u/208883?v=4)](https://github.com/guilhermeblanco "guilhermeblanco (19 commits)")[![jwage](https://avatars.githubusercontent.com/u/97422?v=4)](https://github.com/jwage "jwage (15 commits)")[![comfortablynumb](https://avatars.githubusercontent.com/u/556188?v=4)](https://github.com/comfortablynumb "comfortablynumb (9 commits)")[![robocoder](https://avatars.githubusercontent.com/u/922051?v=4)](https://github.com/robocoder "robocoder (8 commits)")[![djlambert](https://avatars.githubusercontent.com/u/1187338?v=4)](https://github.com/djlambert "djlambert (7 commits)")[![l3pp4rd](https://avatars.githubusercontent.com/u/132389?v=4)](https://github.com/l3pp4rd "l3pp4rd (5 commits)")[![arendjantetteroo](https://avatars.githubusercontent.com/u/713066?v=4)](https://github.com/arendjantetteroo "arendjantetteroo (3 commits)")[![marijn](https://avatars.githubusercontent.com/u/65233?v=4)](https://github.com/marijn "marijn (2 commits)")[![makasim](https://avatars.githubusercontent.com/u/143206?v=4)](https://github.com/makasim "makasim (2 commits)")[![leek](https://avatars.githubusercontent.com/u/60204?v=4)](https://github.com/leek "leek (2 commits)")[![jmikola](https://avatars.githubusercontent.com/u/244663?v=4)](https://github.com/jmikola "jmikola (2 commits)")[![nlegoff](https://avatars.githubusercontent.com/u/511494?v=4)](https://github.com/nlegoff "nlegoff (1 commits)")[![ornicar](https://avatars.githubusercontent.com/u/140370?v=4)](https://github.com/ornicar "ornicar (1 commits)")[![peterhorne](https://avatars.githubusercontent.com/u/1069142?v=4)](https://github.com/peterhorne "peterhorne (1 commits)")[![pscheit](https://avatars.githubusercontent.com/u/488189?v=4)](https://github.com/pscheit "pscheit (1 commits)")[![rubensayshi](https://avatars.githubusercontent.com/u/649160?v=4)](https://github.com/rubensayshi "rubensayshi (1 commits)")[![sliver](https://avatars.githubusercontent.com/u/6036?v=4)](https://github.com/sliver "sliver (1 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (1 commits)")[![arnaud-lb](https://avatars.githubusercontent.com/u/365207?v=4)](https://github.com/arnaud-lb "arnaud-lb (1 commits)")

---

Tags

database

### Embed Badge

![Health badge](/badges/expio-neo4j-data-fixtures/health.svg)

```
[![Health](https://phpackages.com/badges/expio-neo4j-data-fixtures/health.svg)](https://phpackages.com/packages/expio-neo4j-data-fixtures)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k605.0M6.5k](/packages/doctrine-dbal)[doctrine/orm

Object-Relational-Mapper for PHP

10.2k295.3M7.2k](/packages/doctrine-orm)[doctrine/doctrine-bundle

Symfony DoctrineBundle

4.8k249.9M4.0k](/packages/doctrine-doctrine-bundle)[doctrine/migrations

PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is a very easy to use and a powerful tool.

4.8k217.3M518](/packages/doctrine-migrations)[doctrine/data-fixtures

Data Fixtures for all Doctrine Object Managers

2.9k143.6M571](/packages/doctrine-data-fixtures)[robmorgan/phinx

Phinx makes it ridiculously easy to manage the database migrations for your PHP app.

4.5k48.7M444](/packages/robmorgan-phinx)

PHPackages © 2026

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