codeedu / zend-doctrine-fixture
Zend Library that provides Doctrine Data-Fixture functionality
Installs: 2 899
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- php: ^7.1
- codeedu/zendexpr-doctrine-fixture: 0.1.0
- zendframework/zend-modulemanager: ^2.7
Requires (Dev)
- phpunit/phpunit: 6.0.0
This package is auto-updated.
Last update: 2024-12-18 08:51:30 UTC
README
This library provides integration with Zend Framework and Doctrine Data Fixture. Also support PSR-11. It's based in zendexpr-doctrine-fixture
Get started
Instalation
composer require codeedu/zend-doctrine-fixture:0.0.1
Registering Fixtures
To register fixtures add the fixtures in your configuration.
[ 'doctrine' => [ 'fixtures' => [ 'MyFixtures' => __DIR__ . '/../src/Fixture', ] ] ];
Register the module in modules.config.php:
'CodeEdu\DoctrineFixture'
Usage
Command Line
Access the Doctrine command line as following
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:
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; } }