drakulitka/doctrine-data-fixture-module
Composer 安装命令:
composer require drakulitka/doctrine-data-fixture-module
包简介
Zend Framework 3 Module that provides Doctrine Data-Fixture functionality
README 文档
README
Introduction
This is fork from dkorsak/doctrine-data-fixture-module.
The DoctrineDataFixtureModule module intends to integrate Doctrine2 ORM Data Fixtures with Zend Framework 3.
Installation
Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.
$ php composer.phar require drakulitka/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' => [ 'YourModuleName' => __DIR__ . '/../src/Fixture', ], ], ];
Usage
Default
./vendor/bin/doctrine-module orm:fixtures:load
Purge with truncate and without confirmation
./vendor/bin/doctrine-module orm:fixtures:load -n --purge-with-truncate
Append data instead of delete
./vendor/bin/doctrine-module orm:fixtures:load -n --append
How to inject container into fixtures file
<?php namespace YourModuleName\Fixture; use Doctrine\Common\DataFixtures\FixtureInterface; use Doctrine\Common\Persistence\ObjectManager; use DoctrineDataFixtureModule\ContainerAwareInterface; use DoctrineDataFixtureModule\ContainerAwareTrait; class LoadUser implements FixtureInterface, ContainerAwareInterface { use ContainerAwareTrait; /** * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $myService = $this->container->get('my_service'); } }
统计信息
- 总下载量: 56
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-06-27