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(3mo ago)613.4k↓35.6%2[4 issues](https://github.com/teamneusta/pimcore-fixture-bundle/issues)[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 today

READMEChangelog (8)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/'
    ```

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 your local machine, instance identification for Pimcore 12 is needed.

Copy the `compose.override.yaml.dist` file to `compose.override.yaml`:

```
cp -n compose.override.yaml.dist compose.override.yaml
```

And replace all `replace_with_secret` values with your data.

Then install the dependencies:

```
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
```

For the tests there is a different script that includes a database setup.

```
bin/run-tests
```

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance69

Regular maintenance activity

Popularity31

Limited adoption so far

Community20

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

98d 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 (19 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 (5 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)")[![sebo32](https://avatars.githubusercontent.com/u/11462912?v=4)](https://github.com/sebo32 "sebo32 (1 commits)")[![mike4git](https://avatars.githubusercontent.com/u/5848798?v=4)](https://github.com/mike4git "mike4git (1 commits)")[![nsd0malbrecht](https://avatars.githubusercontent.com/u/282839629?v=4)](https://github.com/nsd0malbrecht "nsd0malbrecht (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

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[sylius/sylius

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

8.5k5.9M737](/packages/sylius-sylius)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[shopware/storefront

Storefront for Shopware

684.6M236](/packages/shopware-storefront)

PHPackages © 2026

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