playground/doctrine-data-fixture-module

Laminas Module that provides Doctrine Data-Fixture functionality

Maintainers

👁 gregorybesson

Package info

github.com/gregorybesson/doctrine-data-fixture-module

pkg:composer/playground/doctrine-data-fixture-module

Statistics

Installs: 1 230

Dependents: 1

Suggesters: 0

Stars: 0

1.1.4 2022-06-08 07:45 UTC

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT efa0eb95e93dc8b84d6ef7041d5a15e2cbf40355

  • Daniel Korsak <danielkorsak.woop@gmail.com>

moduledoctrinedata-fixturelaminas

This package is auto-updated.

Last update: 2026-06-08 16:18:31 UTC


README

Introduction

This is fork from Houndog/DoctrineDataFixtureModule.

The DoctrineDataFixtureModule module intends to integrate Doctrine2 ORM Data Fixtures with Zend Framework 3.

Installation

Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.

$ php composer.phar require dkorsak/doctrine-data-fixture-module

Then open config/application.config.php and add DoctrineModule, DoctrineORMModule and DoctrineDataFixtureModule to your modules

Registering Fixtures

To register fixtures with Doctrine module add the fixtures in your configuration.

<?php
return array(
 'doctrine' => array(
 'fixture' => array(
 'ModuleName' => __DIR__ . '/../src/ModuleName/Fixture',
 )
 )
);

Usage

Default

./vendor/bin/doctrine-module orm:fixtures:load 

Purge with truncate and without confirmation

./vendor/bin/doctrine-module orm:fixtures:load -n --purge-with-truncate 

Append data instead of delete

./vendor/bin/doctrine-module orm:fixtures:load -n --append

How to inject container into fixtures file

<?php

namespace Application\DataFixtures;

use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use DoctrineDataFixtureModule\ContainerAwareInterface;
use DoctrineDataFixtureModule\ContainerAwareTrait;

class LoadUser implements FixtureInterface, ContainerAwareInterface
{
 use ContainerAwareTrait;

 /**
 * @param ObjectManager $manager
 */
 public function load(ObjectManager $manager)
 {
 $myService = $this->container->get('my_service'); 
 }
}