PHPackages                             aaronbullard/factory-biscuit - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. aaronbullard/factory-biscuit

ActiveLibrary[Testing &amp; Quality](/categories/testing)

aaronbullard/factory-biscuit
============================

Quickly create PHP class instances for testing using Faker and Firehose Hydrator.

v1.0.0(7y ago)15MITPHPPHP ^7.1

Since Nov 24Pushed 7y ago2 watchersCompare

[ Source](https://github.com/aaronbullard/factory-biscuit)[ Packagist](https://packagist.org/packages/aaronbullard/factory-biscuit)[ RSS](/packages/aaronbullard-factory-biscuit/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Factory Biscuit
===============

[](#factory-biscuit)

[![Maintainability](https://camo.githubusercontent.com/5536c009138d7382885fbfdc31ea5c3b64ee56f80e1a8edc22cd1d5e42dfd4b0/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f30646630613964633038636433323161656231332f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/aaronbullard/factory-biscuit/maintainability)[![Test Coverage](https://camo.githubusercontent.com/56f6fb65bbcdee53c2ad4e93a3762e4a22f755929e65d96b5adbb0edcb5af92b/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f30646630613964633038636433323161656231332f746573745f636f766572616765)](https://codeclimate.com/github/aaronbullard/factory-biscuit/test_coverage)

Quickly create PHP class instances for testing using Faker and Firehose Hydrator.

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

[](#installation)

### Library

[](#library)

```
git clone git@github.com:aaronbullard/factory-biscuit.git
```

### Composer

[](#composer)

[Install PHP Composer](https://getcomposer.org/doc/00-intro.md)

```
composer require aaronbullard/factory-biscuit
```

### Testing

[](#testing)

```
composer test
```

Usage
-----

[](#usage)

Define your factories

```
// Factories.php

use Faker\Generator;
use FactoryBiscuit\Factory;
use FactoryBiscuit\Tests\Mocks\Entity\Foo;
use FactoryBiscuit\Tests\Mocks\Entity\Bar;

$factory->define(Foo::class, function(Generator $faker, Factory $factory){
    return [
        'bar' => function() use ($factory){
            return $factory->of(Bar::class)->make();
        },
        'baz' => $faker->word,
        'qux' => $faker->word
    ];
});

$factory->define(Bar::class, function(Generator $faker, Factory $factory){
    return [
        'bar' => $faker->word
    ];
});
```

Load your factory file

```
use FactoryBiscuit\Factory;

$factory = new Factory();

$factory->load(__DIR__ . '/Factories.php');
```

Examples
--------

[](#examples)

Create an instance

```
$foo = $factory->of(Foo::class)->make();

$this->assertInstanceOf(Foo::class, $foo);
```

Create multiple instances

```
$foos = $factory->of(Foo::class)->times(3)->make();

$this->assertInstanceOf(Foo::class, $foos[0]);
$this->assertCount(3, $foos);
```

Override attributes of an instance

```
$foo = $factory->of(Foo::class)->make([
    'baz' => 'newBaz'
]);

$this->assertEquals('newBaz', $foo->baz());
```

Create a specially defined instance type

```
// Create a factory of class Foo with settings of 'colors'
$factory->defineAs(Foo::class, 'colors', function($faker, $factory){
    return [
        'bar' => 'red',
        'baz' => 'green',
        'qux' => 'blue'
    ];
});

$foo = $factory->of(Foo::class, 'colors')->make();

$this->assertInstanceOf(Foo::class, $foo);
$this->assertEquals('red', $foo->bar());
$this->assertEquals('green', $foo->baz());
```

Implement the FactoryBiscuit\\ManagerRegistry interface to persist instances upon creation

```
$factory = new Factory(Faker::create(), $managerRegistry);

// call the 'create' method to create a persisted instance
$user = $factory->of(User::class)->create();

$this->assertInstanceOf(User::class, $user);
$this->assertTrue(
    DB::table('users')->where('id', '=', $user->id)->exists()
);
```

For more examples, see the tests: `tests\FactoryTest.php`

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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

Unknown

Total

1

Last Release

2726d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/085d40a129f9424a85543852f2c8d2d6cdce7e3f0e4fe6b058ea7eb51edae400?d=identicon)[aaronbullard](/maintainers/aaronbullard)

---

Top Contributors

[![aaronbullard](https://avatars.githubusercontent.com/u/4197300?v=4)](https://github.com/aaronbullard "aaronbullard (7 commits)")

---

Tags

testingfactory

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aaronbullard-factory-biscuit/health.svg)

```
[![Health](https://phpackages.com/badges/aaronbullard-factory-biscuit/health.svg)](https://phpackages.com/packages/aaronbullard-factory-biscuit)
```

###  Alternatives

[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.6k](/packages/mockery-mockery)[behat/mink

Browser controller/emulator abstraction for PHP

1.6k86.1M606](/packages/behat-mink)[league/factory-muffin

The goal of this package is to enable the rapid creation of objects for the purpose of testing.

53713.6M46](/packages/league-factory-muffin)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[behat/mink-browserkit-driver

Symfony2 BrowserKit driver for Mink framework

54462.0M318](/packages/behat-mink-browserkit-driver)[dg/bypass-finals

Removes final keyword from source code on-the-fly and allows mocking of final methods and classes

56426.3M456](/packages/dg-bypass-finals)

PHPackages © 2026

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