PHPackages                             globalprofessionalsearch/popov - 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. globalprofessionalsearch/popov

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

globalprofessionalsearch/popov
==============================

Plain Old Php Object Factory for fixture generation.

1.0.0(10y ago)0187[1 issues](https://github.com/globalprofessionalsearch/popov/issues)MITPHPPHP &gt;=5.4.0

Since Jan 13Pushed 10y ago2 watchersCompare

[ Source](https://github.com/globalprofessionalsearch/popov)[ Packagist](https://packagist.org/packages/globalprofessionalsearch/popov)[ Docs](https://github.com/globalprofessionalsearch/popov)[ RSS](/packages/globalprofessionalsearch-popov/feed)WikiDiscussions master Synced 3w ago

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

Popov
=====

[](#popov)

[![Build Status](https://camo.githubusercontent.com/28bcb9ba5469794b270321e421605fea4b83f59a9b1ad5a8888153131accdac3/68747470733a2f2f7472617669732d63692e6f72672f676c6f62616c70726f66657373696f6e616c7365617263682f706f706f762e737667)](https://travis-ci.org/globalprofessionalsearch/popov)

> Plain Old Php Object Factory

This is a library for generating object graphs in PHP. It's primarily used in conjunction with other libraries to generate data fixtures. It does not include facilities for persisting data to a database; it's up to the user to determine the best method for doing so.

Why write this?

Many fixture libraries available make assumptions about the underlying storage mechanism, or are fairly complicated. For some tests it may be enough to have access to objects that would have been fetched from the data store, without needing to involve that layer in the actual test. But in an integration test you do want the database layer involved. Popov lets you define your fixture models in a way that is relatively simple, but still useful in multiple contexts. By not making assumptions about persistence, you are free to integrate this into your applications in whatever manner is the most suitable, and maintain full control.

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

[](#installation)

Add it to your project's composer.json:

```
{
    "require": {
        "globalprofessionalsearch/popov": "~1.0"
    }
}

```

Usage
-----

[](#usage)

Below are usage examples, starting with the simplest, and increasing in complexity. Since a fixture definition often requires the use of closures, and since Faker is so widely used for generating data points, we highly recommend using the `league/factory-muffin-faker` library in conjunction with Popov. Most of the examples below use it, and you'll see that the use of facades greatly reduces the need to manually wrap field definitions in closures.

The examples below show defining pools of fictional classes that may be in an application. It's assumed that these classes exist and provide getters/setters for the attributes described. This is not a requirement - Popov will use reflection to set any public/protected/private properties defined.

Each example below adds to the previous one.

### Defining Pools

[](#defining-pools)

Let's assume we have users and groups, and we need to generate fake instances of each. The example below defines two pools of objects with a preset number of instances in each. When you define a pool, you provide the fully qualified class name (FQCN) to be used when creating the objects, and an option number of instances to be created when the pool is initialized. Here we will define pools that generate 100 users and 20 groups:

```
