PHPackages                             voldern/phactory - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. voldern/phactory

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

voldern/phactory
================

PHP data factory

116PHP

Since Apr 29Pushed 13y ago1 watchersCompare

[ Source](https://github.com/voldern/phactory)[ Packagist](https://packagist.org/packages/voldern/phactory)[ RSS](/packages/voldern-phactory/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

PHP data factory
================

[](#php-data-factory)

Usage
-----

[](#usage)

### Installation

[](#installation)

Add `voldern/phactory` as a dev dependency using composer.

```
{
  "require-dev": {
    "voldern/phactory": "dev-master"
  }
}
```

### Defining a factory

[](#defining-a-factory)

By default factories should recide in a folder named `factories` and the filename should be the same as the factory name.

Create a class extending `\Phactory\Phactory` and return the attributes configuration from a method named `getFieldsConfig`.

```
class InteractionFactory extends \Phactory\Phactory {
    protected function getFieldsConfig() {
        return array(
            'feedModuleId' => array(
                'type' => '\Phactory\Type\MongoId',
                'generator' => 'random'
             ),
            'type' => array(
                'type' => '\Phactory\Type\String',
                'generator' => 'static',
                'value' => 'interaction'
            ),
            'title' => array(
                'type' => '\Phactory\Type\String',
                'generator' => 'random',
                'values' => array('Tittelen', 'Dette er en tittel', 'Nyhetssak',
                    'VM 2013 Dag 1', 'EM 2012')
            ),
            'name' => array(
                'type' => '\Phactory\Type\String',
                'generator' => 'random',
                'values' => array('VM 2013', 'EM 2012', 'Navnet er langt', 'Dette er en test')
            ),
            'moderated' => array(
                'type' => '\Phactory\Type\Boolean',
                'generator' => 'static',
                'value' => false
            ),
            'permissions' => array(
                'type' => '\Phactory\Type\ArrayType',
                'generator' => 'static',
                'value' => array()
            ),
            'startDate' => array(
                'type' => '\Phactory\Type\DateTime',
                'generator' => 'static',
                'value' => 'now'
            ),
            'endDate' => array(
                'type' => '\Phactory\Type\DateTime',
                'generator' => 'random',
                'range' => array('min' => '+5 minutes', 'max' => '+20 minutes')
            ),
            'refreshRate' => array(
                'type' => '\Phactory\Type\Integer',
                'generator' => 'random',
                'range' => array('min' => 5, 'max' => 30)
            )
        );
    }
}
```

### Running

[](#running)

Use the phactory CLI located in `bin/` or `vendor/bin/`.

The currently supported commands are:

- List factories: `phactory phactory:list`
- Populate DB using factory: `phactory phactory:populate [--dir=] [-f|--file=] [--host=] [-db|--database=] [-c|--cleanup] factory table [count]`

License
-------

[](#license)

"THE BEER-WARE LICENSE":

Copyright (C) 2013 Espen Volden

As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me one or more beers in return.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22524?v=4)[Espen Volden](/maintainers/voldern)[@voldern](https://github.com/voldern)

### Embed Badge

![Health badge](/badges/voldern-phactory/health.svg)

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

###  Alternatives

[sherlockode/configuration-bundle

Symfony bundle for user-defined configuration values

3119.7k](/packages/sherlockode-configuration-bundle)

PHPackages © 2026

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