PHPackages                             feffel/felfactory - 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. feffel/felfactory

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

feffel/felfactory
=================

v0.1.0(6y ago)17MITPHPPHP &gt;=7.2

Since Jul 20Pushed 6y ago1 watchersCompare

[ Source](https://github.com/feffel/felfactory)[ Packagist](https://packagist.org/packages/feffel/felfactory)[ Docs](https://github.com/feffel/felfactory)[ RSS](/packages/feffel-felfactory/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (11)Versions (2)Used By (0)

felfactory
==========

[](#felfactory)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dc0d241c6f5348b07f2f819533f5ae5956e377044e5297080d0fb6709c81ea36/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66656666656c2f66656c666163746f72792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/feffel/felfactory)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/28b685d592f80df5536692423fdca0e50762c63c2d6398d29396aada68a8dd4b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f6d2f66656666656c2f66656c666163746f72792f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.com/feffel/felfactory)[![Coverage Status](https://camo.githubusercontent.com/922380bf2e27fac090d2b40f2a31bbeb612a48e602eebc2bd71bda000baadd61/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f636f7665726167652f66656666656c2f66656c666163746f72792e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/feffel/felfactory/test_coverage)[![Quality Score](https://camo.githubusercontent.com/8324836b469ba3d193189bb82d98635525b51023c662698bdd3885b8baab5e00/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f66656666656c2f66656c666163746f72792e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/feffel/felfactory/maintainability)[![Total Downloads](https://camo.githubusercontent.com/185e13ddb6eedae5241bb19838ddcbac518b5751f2c0c150439fcc4bf822b02e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66656666656c2f66656c666163746f72792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/feffel/felfactory)

felfactory is a library that generates objects full of fake data for you. Whether you need to randomize test data, bootstrap your database, fill-in your persistence to stress test it, or anonymize data taken from a production service.

Powered by [Faker's](https://github.com/fzaninotto/Faker) data generators.

Table of Contents
=================

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Configuration](#configuration)
- [Model Definitions](#model-definitions)
- [How it works](#how-it-works)
- [Contributing](#contributing)
- [License](#license)

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

[](#installation)

via composer

```
composer require feffel/felfactory
```

Basic Usage
-----------

[](#basic-usage)

Pass a class name to your factory instance, it will create and fill properties with the appropriate type of data.

```
class Person
{
    private $firstName;

    private $lastName;

    private $address;
}

$factory = new \felfactory\Factory();
$person  = $factory->generate(Person::class);
var_dump($person);

//  class Person#2407 (3) {
//    private $firstName => string(6) "Breana"
//    private $lastName  => string(7) "Okuneva"
//    private $address   => string(43) "37382 Chanel Point Steuberchester, AR 83395"
//  }
```

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

[](#configuration)

Configuration uses enviornment variables, add these to your environment or add a `.env` file to your root project dir.

VariableDefaultDescriptionFACTORY\_MAX\_NEST\_LEVEL3The maximum allowed level of object nesting, any objects found after this level will be ignored and set to nullFACTORY\_CIRCLE\_TOLERANCE1Circular references tolerance, default 1 does not allow the generation of any circular or self refrencing objectsFACTORY\_PHP\_FILEnullPhp file path for model definitionsFACTORY\_YAML\_FILEnullYaml file path for model definitionsModel Definitions
-----------------

[](#model-definitions)

You can provide model definitions to customize the generation of a model, the definition does not have to contain all of the properties, the factory will still guess the missing properties.

- **Generate** accepts a faker generator property \[eg: firstName, lastName, phoneNumber, ...\]
- **Value** accepts any php value and passes it down to property \[eg: "string value", 15, null, ...\]
- **ObjectOf** accepts a FQCN and generates an object of this type \[eg: namespace\\models\\Person , Person::class, ...\]
- **ManyOf** accepts any of the previous definitions as it's first parameter and generates an array of it bound by the inclusive range provided by it's second and third parameter.

#### Annotation definition

[](#annotation-definition)

```
use felfactory\Annotation as FCT;

class AnnotatedModel
{
    /**
     * @FCT\Generate("firstName")
     */
    public $firstName;

    /**
     * @FCT\Value("""felfel""")
     */
    protected $lastName;

    /**
     * @FCT\ObjectOf(AddressModel::class)
     */
    public $address;

    /**
     * @FCT\ManyOf(@FCT\Generate("phoneNumber"), 1, 3)
     */
    public $phoneNos;
}
```

#### Php defintion

[](#php-defintion)

```
return [
    AnnotatedModel::class => [
        'firstName' => "generate('firstName')",
        'lastName'  => "value('\"felfel\"')",
        'address'   => "class(felfactory\models\AddressModel)",
        'phoneNos'  => "many(generate('phoneNumber'), 1, 3)"
    ],
];
```

How it works
------------

[](#how-it-works)

The factory does not use the class's original constructor, nor the provided setters if any. All of the initiation process is handled by reflections.

The factory looks for the `@var` annotation on a property to determine it's type, if a definition is found for the property it will be used, otherwise it will be guessed based on type and name of the property.

#### Objects

[](#objects)

If a property is found to be an object it will trigger another factory call to generate it, and the name will be ignored. Interfaces and abstract types will not be generated automatically and will be set to null.

#### Scalar types and Non-annotated properties

[](#scalar-types-and-non-annotated-properties)

Scalar types will be guessed based on the name of the property first, if it doesn't match any of the supported data generators, it's generated based on type.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Credits
-------

[](#credits)

- [felfel](https://github.com/feffel)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

2485d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ebdaa295357f4ceb04d5ef6fb3ba2da57f17ececcb16d03a39ea33343058c77?d=identicon)[feffel](/maintainers/feffel)

---

Top Contributors

[![feffel](https://avatars.githubusercontent.com/u/12562522?v=4)](https://github.com/feffel "feffel (67 commits)")

---

Tags

fakerfixturesdatafakeDummygenerationfelfactory

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/feffel-felfactory/health.svg)

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

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M678](/packages/phpspec-prophecy)[nelmio/alice

Expressive fixtures generator

2.5k43.4M133](/packages/nelmio-alice)[fakerino/fakerino

Faker framework, for generate every kind of fake data for test, database seed, mock responses, other

12214.8k5](/packages/fakerino-fakerino)[willdurand/faker-bundle

Put the awesome Faker lib into the DIC and populate your database with fake data.

2751.2M14](/packages/willdurand-faker-bundle)[bheller/images-generator

Generator of placeholder images for Faker

573.1M3](/packages/bheller-images-generator)[niklongstone/regex-reverse

Regular Expression reverter, generates a string from a provided regular expression

105150.4k4](/packages/niklongstone-regex-reverse)

PHPackages © 2026

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