PHPackages                             torq/object-generator-bundle - 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. torq/object-generator-bundle

ActivePimcore-bundle[Utility &amp; Helpers](/categories/utility)

torq/object-generator-bundle
============================

1.1.0(9mo ago)0326GPL-3.0-or-laterPHP

Since Jun 13Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/TorqIT/object-generator-bundle)[ Packagist](https://packagist.org/packages/torq/object-generator-bundle)[ RSS](/packages/torq-object-generator-bundle/feed)WikiDiscussions main Synced 1mo ago

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

Object Generator Bundle
=======================

[](#object-generator-bundle)

Getting Started
---------------

[](#getting-started)

This bundle is for automatically generating objects using [PHPFaker](https://fakerphp.org/). It uses the object's parameter types and names to recursively generate *real looking* data. This bundle is currently designed with DTOs in mind, but there's nothing stopping you from using it to generate any kind of PHP object - just don't expect it to work for every parameter type yet. The intended usage for now is as such:

```
// define your DTO
class MyDto {
    public ?int $id;
    public ?string $name;
    ...
}
```

```
// Inside a command, or whatever script you use to generate your data

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Torq\ObjectGeneratorBundle\Service\FakeObjectFactory\FakeObjectFactory;

class GenerateDataCommand extends Command {

    // dependency inject the factory
    public function __construct(private FakeObjectFactory $fakeObjectFactory) {}

    public function execute(InputInterface $input, OutputInterface $output)
    {
        // optionally define your config (see FakeObjectFactory::DEFAULT_CONFIG)
        $config = ['useConstructor' => false];

        // generate your dto
        $dto = $this->fakeObjectFactory->generateValue(MyDto::class, $config);

        // do whatever with the generated data, likely create a data object with it.
        $object = new DataObject();
        $object->setId($dto->id);
        $object->setName($dto->name);

        return self::SUCCESS;
    }
}
```

```
// You can override the automatic type checking by using #[GenerateAs]

use Torq\ObjectGeneratorBundle\Service\FakeObjectFactory\GenerateAs;
use Torq\ObjectGeneratorBundle\Service\DataGenerator\NameGenerator;

class AnotherDto {
    public ?int $id;

    // pass the class of the generator you want to use
    #[GenerateAs(NameGenerator::class)]
    public ?string $name;
}
```

Supported Types
---------------

[](#supported-types)

> Recursion isn't fully working yet. The workaround is to just set `maxRecursionDepth` to a large value depending on how many objects you're generating, e.g. like 300 or more.

> Arrays and array-like types are not yet supported generically.

Right now we really only have support for primitives and recursive objects. However, you can very easily define a new custom `DataGenerator` and have the factory use it with no config necessary. Simply have your class either extend AbstractDataGenerator OR implement DataGeneratorInterface and the container will automatically tag it for the factory:

```
use Torq\ObjectGeneratorBundle\Service\DataGenerator\AbstractDataGenerator;
use Torq\ObjectGeneratorBundle\Service\DataGenerator\DataGeneratorInterface;

// Recommend extending AbstractDataGenerator to get utilities
class MyEmojiGenerator extends AbstractDataGenerator implements DataGeneratorInterface {
    // $config is passed through from factory->generateValue, maps to faker fn arguments
    public function generateValue(string $type, ?string $name = null, array $config = [])
    {
        // getConfigParser convenience utility comes from AbstractDataGenerator
        $parser = $this->getConfigParser($config);
        return $this->faker->emoji(...$parser('emoji'));
    }

    // Used to finely filter out generators per parameter during generation
    public function supportsGeneration(string $type, ?string $name = null): bool
    {
        return $type === 'string';
    }

    // Used to broadly filter generators prior to generation
    public function getSupportedTypes(): array
    {
        // Expected types found here: https://www.php.net/manual/en/reflectionnamedtype.getname.php
        return ['string'];
    }

    // Used to pick which generator from those where supportsGeneration is true and getSupportedTypes matches
    public function getPriority(): int
    {
        // default is 0, use positive values to increase priority, negative to decrease
        return 0;
    }
}
```

If you end up defining any custom generators you think are generic/useful enough for every project, feel free to open a PR to this project to include them as part of the default generators.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance57

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 90% 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 ~59 days

Total

2

Last Release

280d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/58705850?v=4)[TORQ](/maintainers/TorqIT)[@TorqIT](https://github.com/TorqIT)

---

Top Contributors

[![rjjackson22](https://avatars.githubusercontent.com/u/38430762?v=4)](https://github.com/rjjackson22 "rjjackson22 (9 commits)")[![nick-compassaq](https://avatars.githubusercontent.com/u/68865874?v=4)](https://github.com/nick-compassaq "nick-compassaq (1 commits)")

### Embed Badge

![Health badge](/badges/torq-object-generator-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/torq-object-generator-bundle/health.svg)](https://phpackages.com/packages/torq-object-generator-bundle)
```

###  Alternatives

[verbb/formie

The most user-friendly forms plugin for Craft.

101372.9k40](/packages/verbb-formie)[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52664.9k12](/packages/solspace-craft-freeform)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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