PHPackages                             teamneusta/pimcore-fixture-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. teamneusta/pimcore-fixture-bundle

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

teamneusta/pimcore-fixture-bundle
=================================

Provide basic functionality to enable installing fixtures in Pimcore

3.0.0(1mo ago)611.9k↓38.1%2[2 PRs](https://github.com/teamneusta/pimcore-fixture-bundle/pulls)MITPHPPHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0CI passing

Since Apr 24Pushed 2mo ago9 watchersCompare

[ Source](https://github.com/teamneusta/pimcore-fixture-bundle)[ Packagist](https://packagist.org/packages/teamneusta/pimcore-fixture-bundle)[ RSS](/packages/teamneusta-pimcore-fixture-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (34)Versions (12)Used By (0)

Pimcore Fixture Bundle
======================

[](#pimcore-fixture-bundle)

Provides a way to manage and execute the loading of data fixtures in Pimcore.

It can be useful for testing purposes or for seeding a database with initial data.

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

[](#installation)

1. **Require the bundle**

    ```
    composer require teamneusta/pimcore-fixture-bundle
    ```
2. **Enable the bundle**

    Add the Bundle to your `config/bundles.php`:

    ```
    Neusta\Pimcore\FixtureBundle\NeustaPimcoreFixtureBundle::class => ['test' => true],
    ```
3. **Register your Fixtures Folder for Service autoconfiguration**

    Depending on where you want to create your Fixtures, or if they should only be accessible during test execution.

    ```
    when@test:
      services:
        App\Tests\Fixture\:
          autoconfigure: true
          resource: '../tests/Fixture/'
    ```

### Upgrading From an Earlier Version

[](#upgrading-from-an-earlier-version)

Fixtures are now considered actual services and are loaded through Dependency Injection (DI). To align with this approach, you’ll need to update your Fixture classes by moving service dependencies from the `create` method to the constructor. If your Fixture relies on other Fixtures, implement the `HasDependencies` interface.

Here are the key changes:

1. **Fixture Interface Update**
    The old fixture interface `Neusta\Pimcore\FixtureBundle\Fixture` has been replaced with `Neusta\Pimcore\FixtureBundle\Fixture\Fixture`. You can also extend from `Neusta\Pimcore\FixtureBundle\Fixture\AbstractFixture` to implement your Fixtures.
2. **Fixtures as Services**
    Fixtures must be made available in the Dependency Injection container to be discovered. To do this, tag them with `neusta_pimcore_fixture.fixture`, or use autoconfiguration for automatic tagging.
3. **Change of the `create` Method**
    The signature of the `create` method has been modified. It no longer takes any arguments, meaning all dependencies must be specified via `HasDependencies`.
4. **Specifying Inter-Fixture Dependencies**
    If your Fixture depends on others, use the `HasDependencies` interface to specify these dependencies. Additional guidance is available in the section "[Referencing Fixtures and Depending on Other Fixtures](#referencing-fixtures-and-depending-on-other-fixtures)".

Make sure to update your Fixture classes according to these changes to ensure proper functionality and compatibility with this Bundle.

Usage
-----

[](#usage)

### Writing Fixtures

[](#writing-fixtures)

Data fixtures are PHP service classes where you create objects and persist them to the database.

Imagine that you want to add some `Product` objects to your database. To do this, create a fixture class and start adding products:

```
use Neusta\Pimcore\FixtureBundle\Fixture\AbstractFixture;
use Pimcore\Model\DataObject\Product;

final class ProductFixture extends AbstractFixture
{
    public function create(): void
    {
        for ($i = 1; $i setParentId(1);
            $product->setPublished(true);
            $product->setKey("Product {$i}");
            // ...

            $product->save();
        }
    }
}
```

### Referencing Fixtures and Depending on Other Fixtures

[](#referencing-fixtures-and-depending-on-other-fixtures)

Suppose you want to link a `Product` fixture to a `Group` fixture. To do this, you need to create a `Group` fixture first and keep a reference to it. Later you can use this reference when creating the `Product` fixture.

This process requires the `Group` fixture to exist before the `Product` fixture. You can achieve this ordering by implementing the `HasDependencies` interface.

```
use Neusta\Pimcore\FixtureBundle\Fixture\AbstractFixture;
use Pimcore\Model\DataObject\ProductGroup;

final class ProductGroupFixture extends AbstractFixture
{
    public function create(): void
    {
        $productGroup = new ProductGroup();
        $productGroup->setParentId(1);
        $productGroup->setPublished(true);
        $productGroup->setKey('My Product Group');
        $productGroup->save();

        $this->addReference('my-product-group', $productGroup);
    }
}
```

```
use Neusta\Pimcore\FixtureBundle\Fixture\AbstractFixture;
use Neusta\Pimcore\FixtureBundle\Fixture\HasDependencies;
use Pimcore\Model\DataObject\Product;
use Pimcore\Model\DataObject\ProductGroup;

final class ProductFixture extends AbstractFixture implements HasDependencies
{
    public function create(): void
    {
        $productGroup = $this->getReference('my-product-group', ProductGroup::class);

        $product = new Product();
        $product->setParentId(1);
        $product->setPublished(true);
        $product->setKey('My grouped Product');
        $product->setProductGroup($productGroup);
        $product->save();
    }

    public function getDependencies(): array
    {
        return [
            ProductGroupFixture::class,
        ];
    }
}
```

### Loading Fixtures

[](#loading-fixtures)

#### In Tests

[](#in-tests)

To load fixtures in Tests, we offer the `SelectiveFixtureLoader`. To streamline your test setup, we recommend creating a base class with a method to load fixtures via the `SelectiveFixtureLoader`. Here’s an example demonstrating how to implement this.

```
use Neusta\Pimcore\FixtureBundle\Fixture\Fixture;
use Neusta\Pimcore\FixtureBundle\FixtureLoader\SelectiveFixtureLoader;
use Pimcore\Test\KernelTestCase;

abstract class BaseKernelTestCase extends KernelTestCase
{
    /**
     * @param list $fixtures
     */
    protected function importFixtures(array $fixtures): void
    {
        /** @var SelectiveFixtureLoader $fixtureLoader */
        $fixtureLoader = static::getContainer()->get(SelectiveFixtureLoader::class);
        $fixtureLoader->setFixturesToLoad($fixtures)->loadFixtures();
    }

    protected function tearDown(): void
    {
        \Pimcore\Cache::clearAll();
        \Pimcore::collectGarbage();

        parent::tearDown();
    }
}
```

Use the base class as follows:

```
use Pimcore\Model\DataObject;

final class MyCustomTest extends BaseKernelTestCase
{
    /** @test */
    public function import_fixtures(): void
    {
        $this->importFixtures([
            ProductFixture::class,
        ]);

        $productFixture = DataObject::getByPath('/product-1');

        self::assertNotNull($productFixture);
    }
}
```

#### As Initial Data in Your Project

[](#as-initial-data-in-your-project)

To load fixtures in your local environment or as part of a deployment, two commands are provided:

- `neusta:pimcore-fixture:load` (Loads a defined fixture class.)
- `neusta:pimcore-fixtures:load` (Loads all defined fixture classes.)

Beware that loading a large number of objects may lead to high memory consumption. Should you encounter memory issues when running the commands in `dev` environments you may want to try setting the environment to `prod`. Disabling the debug mode also seems beneficial in terms of memory consumption.

For example, provide these options when using the symfony console:

```
bin/console --env=prod --no-debug neusta:pimcore-fixtures:load
```

### Accessing Services From the Fixtures

[](#accessing-services-from-the-fixtures)

As the Fixtures are just normal PHP services, you can use all DI features like constructor, setter, or property injection as usual.

### Extension and Customization Through Events

[](#extension-and-customization-through-events)

The Bundle provides the following events to facilitate extensions and customization:

1. **`BeforeLoadFixtures`**
    This event is dispatched before any fixture is executed. It contains all the fixtures that are scheduled for execution, accessible via `$event->fixtures`. You can alter the list of fixtures to be loaded by modifying it `$event->fixtures = ...`.
2. **`BeforeExecuteFixture`**
    This event is dispatched for each fixture just before it is executed. Using this event, you can prevent the execution of a specific fixture by setting `$event->preventExecution = true`.
3. **`AfterExecuteFixture`**
    This event is dispatched for each fixture after it has been executed.
4. **`AfterLoadFixtures`**
    This event is dispatched after all relevant fixtures have been executed. It carries the fixtures that have been successfully loaded, which can be accessed through `$event->loadedFixtures`.

Contribution
------------

[](#contribution)

Feel free to open issues for any bug, feature request, or other ideas.

Please remember to create an issue before creating large pull requests.

### Local Development

[](#local-development)

To develop on a local machine, the vendor dependencies are required.

```
bin/composer install
```

We use composer scripts for our main quality tools. They can be executed via the `bin/composer` file as well.

```
bin/composer cs:fix
bin/composer phpstan
bin/composer tests
```

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance88

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~100 days

Recently: every ~158 days

Total

8

Last Release

52d ago

Major Versions

1.0.0 → 2.0.02024-05-02

2.2.2 → 3.0.02026-03-27

PHP version history (3 changes)1.0.0PHP ~8.1.0 || ~8.2.0

2.2.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

3.0.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12913211?v=4)[team neusta SE](/maintainers/teamneusta)[@teamneusta](https://github.com/teamneusta)

![](https://www.gravatar.com/avatar/c7656fdcd61bd3098b9a75612baab050cad75cc52a08c65ad4b7c31eba986b7f?d=identicon)[m0nken](/maintainers/m0nken)

---

Top Contributors

[![jdreesen](https://avatars.githubusercontent.com/u/424602?v=4)](https://github.com/jdreesen "jdreesen (16 commits)")[![m0nken](https://avatars.githubusercontent.com/u/16223110?v=4)](https://github.com/m0nken "m0nken (7 commits)")[![lukadschaak](https://avatars.githubusercontent.com/u/2377363?v=4)](https://github.com/lukadschaak "lukadschaak (4 commits)")[![nehlsen](https://avatars.githubusercontent.com/u/1791962?v=4)](https://github.com/nehlsen "nehlsen (4 commits)")[![cngJo](https://avatars.githubusercontent.com/u/17183555?v=4)](https://github.com/cngJo "cngJo (2 commits)")[![mike4git](https://avatars.githubusercontent.com/u/5848798?v=4)](https://github.com/mike4git "mike4git (1 commits)")[![sebo32](https://avatars.githubusercontent.com/u/11462912?v=4)](https://github.com/sebo32 "sebo32 (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/teamneusta-pimcore-fixture-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/teamneusta-pimcore-fixture-bundle/health.svg)](https://phpackages.com/packages/teamneusta-pimcore-fixture-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

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

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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