PHPackages                             linkorb/haigha - 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. linkorb/haigha

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

linkorb/haigha
==============

Alice fixtures for database tables

v2.8.1(3y ago)2411.2k8[1 issues](https://github.com/linkorb/haigha/issues)3MITPHPPHP &gt;=7.1CI failing

Since Feb 25Pushed 2y ago9 watchersCompare

[ Source](https://github.com/linkorb/haigha)[ Packagist](https://packagist.org/packages/linkorb/haigha)[ RSS](/packages/linkorb-haigha/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (23)Used By (3)

Tip

Haigha has been superseeded by the brand new [Hatter](https://github.com/linkorb/haigha) - similar features, still application independant, but no longer trying to use Alice in a way that it wasn't designed for.

Haigha: Alice fixtures for tables
=================================

[](#haigha-alice-fixtures-for-tables)

[![](https://camo.githubusercontent.com/9c10844f11c8f147b91f99a9836d7a93a82a5990da1d077a8884e14b748d2522/687474703a2f2f332e62702e626c6f6773706f742e636f6d2f2d395f4a74336764663666552f542d32385f5255706f46492f41414141414141414342672f786741784b2d3266674c592f73313630302f4d61726368486172652e6a7067)](https://camo.githubusercontent.com/9c10844f11c8f147b91f99a9836d7a93a82a5990da1d077a8884e14b748d2522/687474703a2f2f332e62702e626c6f6773706f742e636f6d2f2d395f4a74336764663666552f542d32385f5255706f46492f41414141414141414342672f786741784b2d3266674c592f73313630302f4d61726368486172652e6a7067)

[Alice](https://github.com/nelmio/alice) is an *awesome* database fixtures library. It works with Doctrine out-of-the-box, but if you don't use the Doctrine ORM, you'll need custom persisters...

This is where **Haigha** comes in:

> *Haigha lets you use Alice directly with database tables!*

Features
--------

[](#features)

- Supports all standard Alice functionality (ranges, optional data, references, inheritence, etc)
- Supports Faker data providers
- Supports any PDO connection
- No need to write classes, directly persist from yml to your sql database

Example fixture file
--------------------

[](#example-fixture-file)

Haigha uses Alice to load fixture files, so the format is identical ([Details](https://github.com/nelmio/alice)). The only thing to keep in mind is that you use tablenames instead of classnames. Prefix your tablenames with `table.`. For example, if your tablename is called `user`, you use it like this:

```
table.group:
  group_random_users:
    id: 1 # This is important for version ~2.0
    name: Random users

table.user:
  random_user{0..9}:
    group_id: @group_random_users
    username:
    firstname:
    lastname:
    password:
    email:
```

How to use Haigha in your application
-------------------------------------

[](#how-to-use-haigha-in-your-application)

Simply add the following to your `require` or `require-dev` section in your [composer.json](http://getcomposer.org) and run `composer update`:

```
"require": {
  "linkorb/haigha": "^2.0"
}
```

You can now use Haigha in your applications, or use the included command-line tool to load fixtures into your database:

Command-line usage
------------------

[](#command-line-usage)

The haigha command-line tool knows one sub-command: `fixtures:load`.

The first argument is the filename of your fixture definition (yaml).

The second argument is the (optional) database url. If no database url is specified, haigha used your `PDO` environment variable instead.

### Database URL

[](#database-url)

A full URL containing username, password, hostname and dbname. For example:

```
./vendor/bin/haigha fixtures:load examples/random_users.yml mysql://username:password@hostname/dbname

```

### Just a dbname

[](#just-a-dbname)

In this case [linkorb/database-manager](https://github.com/linkorb/database-manager) is used for loading database connection details (server, username, password, etc) from .conf files (read project readme for more details).

In a nutshell - you must have a `database_name.conf` file at `/share/config/database/` as described at [database-manager's documentation](https://github.com/linkorb/database-manager#database-configuration-files).

```
./vendor/bin/haigha fixtures:load examples/random_users.yml dbname
```

Library usage:
--------------

[](#library-usage)

You can use Haigha in your own application like this:

```
// Instantiate a new Alice loader
$loader = new Nelmio\Alice\Fixtures\Loader();

// Add the Haigha instantiator
$instantiator = new Haigha\TableRecordInstantiator();
$loader->addInstantiator($instantiator);

// Load (Haigha) objects from a Alice yml file
$objects = $loader->load('examples/random_users.yml');

// Instantiate the Haigha PDO persister, and pass a PDO connection
$persister = new PdoPersister($pdo);

// Persist the Haigha objects on the PDO connection
$persister->persist($objects);
```

Test
----

[](#test)

Customize `phpunit.xml`:

```
cp phpunit.xml.dist phpunit.xml

```

Run:

```
vendor/bin/phpunit

```

License
-------

[](#license)

MIT (see [LICENSE.md](LICENSE.md))

Brought to you by the LinkORB Engineering team
----------------------------------------------

[](#brought-to-you-by-the-linkorb-engineering-team)

[![](https://camo.githubusercontent.com/62fb66b034de7ea7fca9fd9776424b5348daa76ef8622caf92c2f7622003e5ef/687474703a2f2f7777772e6c696e6b6f72622e636f6d2f642f6d6574612f74696572312f696d616765732f6c696e6b6f7262656e67696e656572696e672d6c6f676f2e706e67)](https://camo.githubusercontent.com/62fb66b034de7ea7fca9fd9776424b5348daa76ef8622caf92c2f7622003e5ef/687474703a2f2f7777772e6c696e6b6f72622e636f6d2f642f6d6574612f74696572312f696d616765732f6c696e6b6f7262656e67696e656572696e672d6c6f676f2e706e67)
Check out our other projects at [linkorb.com/engineering](http://www.linkorb.com/engineering).

Btw, we're hiring!

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 65.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 ~138 days

Recently: every ~413 days

Total

22

Last Release

1200d ago

Major Versions

v1.2.0 → v2.0.02015-09-11

PHP version history (3 changes)v1.1.0PHP &gt;=5.3

v2.7.0PHP ^7.1

v2.8.1PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/1db66b320db18b8036ea68211b7d8a39e7c6da97e6fd29f59a50380ebb69d0bb?d=identicon)[joostfaassen](/maintainers/joostfaassen)

---

Top Contributors

[![joostfaassen](https://avatars.githubusercontent.com/u/411113?v=4)](https://github.com/joostfaassen "joostfaassen (29 commits)")[![igormukhingmailcom](https://avatars.githubusercontent.com/u/6544038?v=4)](https://github.com/igormukhingmailcom "igormukhingmailcom (7 commits)")[![h-wang](https://avatars.githubusercontent.com/u/3410322?v=4)](https://github.com/h-wang "h-wang (3 commits)")[![Seldaek](https://avatars.githubusercontent.com/u/183678?v=4)](https://github.com/Seldaek "Seldaek (3 commits)")[![pakulin-dev](https://avatars.githubusercontent.com/u/94841486?v=4)](https://github.com/pakulin-dev "pakulin-dev (1 commits)")[![prajapati-kaushik](https://avatars.githubusercontent.com/u/10140681?v=4)](https://github.com/prajapati-kaushik "prajapati-kaushik (1 commits)")

---

Tags

fixturesalicewonderlandmarch hare

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/linkorb-haigha/health.svg)

```
[![Health](https://phpackages.com/badges/linkorb-haigha/health.svg)](https://phpackages.com/packages/linkorb-haigha)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[theofidry/alice-data-fixtures

Nelmio alice extension to persist the loaded fixtures.

32328.5M70](/packages/theofidry-alice-data-fixtures)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[h4cc/alice-fixtures-bundle

Symfony2 Bundle for loading fixture data with the Alice library.

76314.2k7](/packages/h4cc-alice-fixtures-bundle)[hautelook/alice-bundle

Symfony bundle to manage fixtures with Alice and Faker.

19519.4M34](/packages/hautelook-alice-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

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