feeltr/fixture-loader-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

Doctrine fixtures loader during database migrations

0.3 2016-01-24 15:58 UTC

This package is not auto-updated.

Last update: 2018-04-28 12:32:32 UTC


README

This bundle allows you to execute Doctrine fixtures during database migrations

Installation

First install the package using composer

$ composer require feeltr/fixture-loader-bundle

After installing the package, add the bundle in app/AppKernel.php

// AppKernel::registerBundles()
$bundles = array(
    // ...
    new Feeltr\Bundle\FixtureLoaderBundle\FixtureLoaderBundle(),
    // ...
);

Usage

Extend from FixtureLoaderMigration to have access to the fixture loader during migrations:

<?php

namespace Application\Migrations;

use Feeltr\Bundle\FixtureLoaderBundle\Component\FixtureLoaderMigration;

class Version20150809022933 extends FixtureLoaderMigration
{
    /**
     * @param Schema $schema
     */
    public function up(Schema $schema)
    {
        // ...
    }

    /**
     * @param Schema $schema
     */
    public function down(Schema $schema)
    {
        // ...
    }

    /**
     * @param Schema $schema
     */
    public function postUp(Schema $schema)
    {
        $this->loadFixtures([
            new Fixture(),
            ...
        ]);
    }
}

Additionally, you can use the fixture loader defined in the service container:

$fixtureLoader = $this->container->get('feeltr_fixture_loader');
$fixtureLoader->load([new Fixture()]);

Finally, you can disable logging using symfony bundle configuration in app/config/config.yml. By default, logging is enabled.

feeltr_fixture_loader:
    logging: false