About
This library provides integration with Zend Framework and Doctrine Data Fixture. Also support PSR-11.
It's based in zendexpr-doctrine-fixture, (*1)
Get started
Instalation
composer require codeedu/zend-doctrine-fixture:0.0.1
Registering Fixtures
To register fixtures add the fixtures in your configuration., (*2)
[
'doctrine' => [
'fixtures' => [
'MyFixtures' => __DIR__ . '/../src/Fixture',
]
]
];
Register the module in modules.config.php:, (*3)
'CodeEdu\DoctrineFixture'
Usage
Command Line
Access the Doctrine command line as following, (*4)
Import
./vendor/bin/doctrine-module data-fixture:import
Dependency Injection with Fixtures
This library provides inject the service container in fixtures. So add interface FixtureContainerInterface, see below:, (*5)
class MyFixture implements FixtureInterface, FixtureContainerInterface
{
private $container;
public function load(ObjectManager $manager){
$myService = $this->container->get(MyService::class);
}
public function getContainer()
{
return $this->container;
}
public function setContainer(ContainerInterface $container)
{
$this->container = $container;
}
}