DoctrineDataFixture Module for Zend Framework 3
This is a port for ZF3 of Hounddog's orignal code to make fixtures supported in the form of a CLI command.
Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.
$ composer require rvdlee/doctrine-data-fixture-module
config/application.config.php and add
DoctrineDataFixtureModule to your
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, ], ], ];
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.