PHPackages                             mgdsoft/fixtures-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. [HTTP &amp; Networking](/categories/http)
4. /
5. mgdsoft/fixtures-generator-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

mgdsoft/fixtures-generator-bundle
=================================

This Bundle provides a easy fixture generator for doctrine entities

v1.0.5(7y ago)27551MITPHPPHP ~7.0

Since Feb 15Pushed 7y ago1 watchersCompare

[ Source](https://github.com/MGDSoft/FixturesGeneratorBundle)[ Packagist](https://packagist.org/packages/mgdsoft/fixtures-generator-bundle)[ RSS](/packages/mgdsoft-fixtures-generator-bundle/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (4)Versions (9)Used By (0)

Fixtures Generator Bundle For Doctrine (Code Generator)
=======================================================

[](#fixtures-generator-bundle-for-doctrine-code-generator)

This bundle generate the fixtures code for doctrine, you can override all code without problems

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

[](#installation)

```
composer require --dev "mgdsoft/fixtures-generator-bundle"

```

Add Bundle
----------

[](#add-bundle)

**For Symfony 4**, bundles.php

```
    MGDSoft\FixturesGeneratorBundle\MgdsoftFixturesGeneratorBundle::class => ['dev' => true],
```

**For Symfony 3**, AppKernel.php

```
    if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
        $bundles[] = new MGDSoft\FixturesGeneratorBundle\MgdsoftFixturesGeneratorBundle()
    }
```

**For Symfony 4 skip this part**, for Symfony 3 configure default path

```
mgdsoft_fixtures_generator:
    fixture_path_default: '%kernel.root_dir%/../src/AppBundle/DataFixtures/ORM' # Default %kernel.root_dir%/DataFixtures/ORM
```

Show me an example ¬¬
---------------------

[](#show-me-an-example-)

Execute command to generate Fixtures, by default it will take all entities for your proyect and will generate all fixtures for dev and test. If you want to create for an entity use **--entity** option, and if you want to create with all his dependencies use **-r** option

```
bin/console mgdsoft:fixtures:generate

```

This execution will create 3 files. **src/DataFixtures/ORM/LibsAuto/AbstractLoadUserFixture.php**, this file is a abstract class you can override all methods in child class, we recommend not to modify this class.

```
namespace App\DataFixtures\ORM\LibsAuto;

use App\Entity\User;
use MGDSoft\FixturesGeneratorBundle\LoaderFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;

abstract class AbstractLoadUserFixture extends AbstractFixture  implements DependentFixtureInterface
{
    /**
     * (Skipped) all parameters to auto complete IDE
     */
    protected function loadRow($key, array $overrideDefaultValues = [])
    {
        $obj = new User();

        $defaultValues = $this->getDefaultValues();

        $properties = array_merge($defaultValues, $overrideDefaultValues);

        foreach ($properties as $property => $value) {
            $this->propertyAccessor->setValue($obj, $property, $value);
        }

        $this->om->persist($obj);
        $this->addReference("user-".$key, $obj);
    }

    protected function getDefaultValues()
    {
        return [

            // ---[ required values ]--- ,
            'username' => 'username',
            'usernameCanonical' => 'usernameCanonical',
            'email' => 'email',
            'emailCanonical' => 'emailCanonical',
            'password' => 'password',
            'roles' => ["ROLE_SUPER_ADMIN"],
            'colour' => 'colour',
            'isOnline' => true,
            'createdAt' => new \DateTime(),
            'updatedAt' => new \DateTime(),
            'salt' => 'salt',
            'enabled' => true,
            'plan' => $this->getReference("plan-1"),

            // ---[ required with default values ]--- ,
            // 'showTips' => true,

            // ---[ non-mandatory fields ]--- ,
            // 'lastLogin' => new \DateTime(),
            // 'confirmationToken' => 'confirmationToken',
            // 'passwordRequestedAt' => new \DateTime(),
            // 'name' => 'name',
            // 'lastName' => 'lastName',
            // 'avatar' => 'avatar',
            // 'initials' => 'initials',
            // 'lang' => 'en',
            // 'planDateEnd' => new \DateTime(),
            // 'stripeSubscriptionId' => 'stripeSubscriptionId',
            // 'userHasEmails' => $this->getReference("user_has_email-1"),
            // 'webPushes' => $this->getReference("user_web_push-1"),
            // 'user_resources' => $this->getReference("user_resources-1"),
            // 'tags' => $this->getReference("tag-1"),
            // 'guest' => $this->getReference("guest-1")
        ];
    }

    public function getDependencies()
    {
        return [
            'App\DataFixtures\ORM\LoadPlanFixture',
            // ---[ non-mandatory fields ]---,
            // 'App\DataFixtures\ORM\LoadUserHasEmailFixture',
            // 'App\DataFixtures\ORM\LoadUserWebPushFixture',
            // 'App\DataFixtures\ORM\LoadUserResourcesFixture',
            // 'App\DataFixtures\ORM\LoadTagFixture',
            // 'App\DataFixtures\ORM\LoadGuestFixture'
        ];
    }
}
```

**src/DataFixtures/ORM/LoadUserFixture.php**, Here you can customize what you want. This class will be loaded when you execute doctrine fixtures (bin/console doctrine:fixtures:load)

```
namespace App\DataFixtures\ORM;

use App\DataFixtures\ORM\LibsAuto\AbstractLoadUserFixture;

class LoadUserFixture extends AbstractLoadUserFixture
{
    protected function loadRows()
    {
        $this->loadRow('1', []);
    }
}
```

And for test purpose is created tests/Fixtures/General/LoadTestUserFixture.php. If you dont want this class you can disable in configuration

```
namespace Tests\Fixtures\General;

use App\DataFixtures\ORM\LibsAuto\AbstractLoadUserFixture;

class LoadTestUserFixture extends AbstractLoadUserFixture
{
    protected function loadRows()
    {
        $this->loadRow('1', []);
    }
}
```

How to insert multiples rows?
-----------------------------

[](#how-to-insert-multiples-rows)

src/DataFixtures/ORM/LoadUserFixture.php

```
namespace App\DataFixtures\ORM;

use App\DataFixtures\ORM\LibsAuto\AbstractLoadUserFixture;

class LoadUserFixture extends AbstractLoadUserFixture
{
    protected function loadRows()
    {
        $this->loadRow('1', ['username' => 'Miguel1', 'email' => 'mgd1@mgdsoftware.com']);
        $this->loadRow('2', ['username' => 'Miguel2', 'email' => 'mgd2@mgdsoftware.com']);
        $this->loadRow('3', ['username' => 'Miguel3', 'email' => 'mgd3@mgdsoftware.com']);
    }
}
```

Each row insert has a doctrine reference with "class Prefix"-"$key"

If you want to add multiple values for an array you must use "|" symbol

```
namespace App\DataFixtures\ORM;

use App\DataFixtures\ORM\LibsAuto\AbstractLoadUserFixture;

class LoadUserFixture extends AbstractLoadUserFixture
{
    protected function loadRows()
    {
        $this->loadRow('1', ['comments|1' => $this->getReference('comment-2'), 'comments|2' => $this->getReference('comment-1') ]);
    }
}
```

For autocomplete fields use **deep-assoc-completion** in phpstorm RECOMMENDED

To see all options execute

```
bin/console mgdsoft:fixtures:generate -h
```

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

[](#configuration)

```
mgdsoft_fixtures_creator:
    abstract_fixture_class: MGDSoft\FixturesGeneratorBundle\LoaderFixtures\AbstractFixture
    entity_path_default:  App\Entity
    template:             //MGDSoft/FixturesGeneratorBundle/DependencyInjection/../Generator/templates/basic.tpl
    template_lib:         //MGDSoft/FixturesGeneratorBundle/DependencyInjection/../Generator/templates/lib.tpl
    fixture_path_default: '%kernel.root_dir%/DataFixtures/ORM'
    php_cs_fixer:         php-cs-fixer
    generate_autocomplete_array_options: true
    test:
        template:             //MGDSoft/FixturesGeneratorBundle/DependencyInjection/../Generator/templates/basic_test.tpl
        enabled:              true
        fixture_path_default: '%kernel.root_dir%/../tests/Fixtures/General'
```

All pull request are welcome 😎

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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

Every ~6 days

Total

8

Last Release

2645d ago

Major Versions

v0.1.5 → v1.0.52019-04-03

PHP version history (2 changes)v0.0.1PHP ^5.5.9|~7.0

v0.1PHP ~7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3816465?v=4)[MiguelGD](/maintainers/MGDSoft)[@MGDSoft](https://github.com/MGDSoft)

---

Top Contributors

[![MGDSoft](https://avatars.githubusercontent.com/u/3816465?v=4)](https://github.com/MGDSoft "MGDSoft (25 commits)")

---

Tags

rest

### Embed Badge

![Health badge](/badges/mgdsoft-fixtures-generator-bundle/health.svg)

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

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[kimai/kimai

Kimai - Time Tracking

4.8k8.7k1](/packages/kimai-kimai)[oro/platform

Business Application Platform (BAP)

642140.7k104](/packages/oro-platform)[api-platform/doctrine-orm

Doctrine ORM bridge

263.9M78](/packages/api-platform-doctrine-orm)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9317.2k55](/packages/open-dxp-opendxp)

PHPackages © 2026

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