rvdlee / doctrine-data-fixture-module
A port for ZF3 of Hounddog's original data-fixture code with the ability to change the executor for fixtures.
Requires
- php: ^7
- doctrine/data-fixtures: *
- doctrine/doctrine-orm-module: ^3.0
- laminas/laminas-dependency-plugin: ^1.0
- php-coveralls/php-coveralls: ^2.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-27 06:49:15 UTC
README
Introduction
This is a port for ZF3 of Hounddog's orignal code to make fixtures supported in the form of a CLI command.
Installation
Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.
$ composer require rvdlee/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 [ 'doctrine' => [ 'fixture' => [ __NAMESPACE__ . '_fixture' => __DIR__ . '/../src/' . __NAMESPACE__ . '/Fixture', ] ] ];
Alternativly you can overwrite the executor that fires off the fixtures. I've made an dist file you can follow to make your own. Executors fall in the service category if you need to make a factory for one.
<?php return [ 'rvdlee' => [ 'doctrine-data-fixture' => [ 'executor' => YourExecutor::class, ], ], 'service_manager' => [ 'factories' => [ YourExecutor::class => YourExecutorFactory::class, ], ], ];
Usage
Command Line
Access the Doctrine command line as following from your project root:
$ ./vendor/bin/doctrine-module data-fixture:import
Why use a custom Executor?
I've made fixtures based on entity meta-data or route config for example. A custom executor can provide such information and pass it along to your fixtures.