PHPackages                             tijmen-wierenga/bogus - 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. tijmen-wierenga/bogus

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

tijmen-wierenga/bogus
=====================

The dummy data factory

v1.0.0(7y ago)31.5k1[1 PRs](https://github.com/TijmenWierenga/Bogus/pulls)1MITPHPPHP ^7.2

Since Feb 19Pushed 6y ago1 watchersCompare

[ Source](https://github.com/TijmenWierenga/Bogus)[ Packagist](https://packagist.org/packages/tijmen-wierenga/bogus)[ RSS](/packages/tijmen-wierenga-bogus/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (7)Used By (1)

Bogus
=====

[](#bogus)

[![Build Status](https://camo.githubusercontent.com/ae0a349f25cf79906d76a6594d4a4b89a0ad3df636c29ee5d3238712d5f652d5/68747470733a2f2f7472617669732d63692e6f72672f54696a6d656e57696572656e67612f426f6775732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/TijmenWierenga/Bogus)

A simple library to quickly generate fake data
----------------------------------------------

[](#a-simple-library-to-quickly-generate-fake-data)

Ever had to deal with the situation where you had to create dummy data to feed to a test? Newing up a lot of entities and passing the required arguments for all of them? Bogus can help you by creating a very simple factory for your entities. Every factory will give you the possibility to define default (random) and overridable attributes for your entities.

It's as simple as:

```
$fixtures = new Fixtures(new UserFactory());
$users = $fixtures->create(User::class, ['city' => 'Amsterdam'], 5); // Generates 5 users from Amsterdam
```

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

[](#installation)

The easiest and recommended way to install Bogus is by making use of [Composer](https://getcomposer.org/)Run this command in the root directory of your project where your `composer.json` file is located:

```
composer require --dev tijmen-wierenga/bogus
```

Most of the time you only want to use this package in an development environment, but if you want to make use it in production, just run the command without the `--dev` flag:

```
composer require tijmen-wierenga/bogus
```

Usage
-----

[](#usage)

The `Fixtures` class contains a single method:

```
final class Fixtures
{
    public function create(string $entityClassName, iterable $attributes, int $amount): Collection;
}
```

This means you'll always call this method in order to generate fixtures. The implementation is highly configurable.

### Factories

[](#factories)

Random data is created through factories. The easiest way to implement a factory is by extending the AbstractFactory:

```
use TijmenWierenga\Bogus\Factory\AbstractFactory;

final class UserFactory extends AbstractFactory
{
    /**
     * Whether or not the Factory creates the entity passed as an argument
     */
    public function creates(string $entityClassName): bool
    {
        return $entityClassName === User::class;
    }

    /**
     * An iterable list of key => value pairs with default values. The result of the merged attributes
     * is passed to the 'create' method.
     */
    protected function attributes(): iterable
    {
        $factory = \Faker\Factory::create();

        return [
            "name" => $factory->firstName,
            "email" => $factory->email
        ];
    }

    /**
     * Creates the actual entity based on the merged attributes
     */
    protected function create(iterable $attributes): object
    {
        return new User($attributes["name"], $attributes["email"]);
    }
}

class User
{
    public function __construct(string $name, string $email)
    {
        $this->name = $name;
        $this->email = $email;
    }
}
```

Next, register the Factory to the Fixtures base class:

```
$fixtures = new Fixtures(new UserFactory());

// Use it
$fixtures->create(User::class); // Returns a Collection with a random user instance
```

View the full [example](examples/abstract-factory.php).

### Overriding properties

[](#overriding-properties)

If you wish to override a random property, you can provide a key-value list with overrides:

```
$user = $fixtures->create(User::class, [
    "name" => "Tijmen"
]); // Will create a user with Tijmen as a name and a random email address
```

### Creating multiple entities at once

[](#creating-multiple-entities-at-once)

```
$users = $fixtures->create(User::class, [], 3); // Will create 3 random users
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 57.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 ~201 days

Total

4

Last Release

2765d ago

Major Versions

v0.0.2 → v1.0.02018-10-16

PHP version history (2 changes)v0.0.1PHP &gt;=7.1

v1.0.0PHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/52381e72d9e3b301a071a0a30cd72592e595fa17838beabb00ac2e7ebbd98275?d=identicon)[TijmenWierenga](/maintainers/TijmenWierenga)

---

Top Contributors

[![TijmenWierenga](https://avatars.githubusercontent.com/u/8513032?v=4)](https://github.com/TijmenWierenga "TijmenWierenga (22 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (13 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (3 commits)")

---

Tags

data-fixturesdummy-datafactoryfake-datafixturesfixturesFake datadummy datadata generator

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tijmen-wierenga-bogus/health.svg)

```
[![Health](https://phpackages.com/badges/tijmen-wierenga-bogus/health.svg)](https://phpackages.com/packages/tijmen-wierenga-bogus)
```

###  Alternatives

[fakerphp/faker

Faker is a PHP library that generates fake data for you.

3.9k358.5M3.5k](/packages/fakerphp-faker)[mbezhanov/faker-provider-collection

A collection of custom providers for the Faker library

2138.6M24](/packages/mbezhanov-faker-provider-collection)[sylius/fixtures-bundle

Configurable fixtures for Symfony applications.

517.7M12](/packages/sylius-fixtures-bundle)[bheller/images-generator

Generator of placeholder images for Faker

573.1M3](/packages/bheller-images-generator)[xefi/faker-php

Faker allows you to generate realistic fake data for your php applications

15116.5k15](/packages/xefi-faker-php)[apoutchika/loremipsum-bundle

Generate paragraphs, sentences and words for your development.

1259.8k](/packages/apoutchika-loremipsum-bundle)

PHPackages © 2026

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