feeltr / fixture-loader-bundle
此包已被弃用且不再维护。未建议替代包。
数据库迁移期间的 Doctrine fixtures 加载器
0.3
2016-01-24 15:58 UTC
Requires
- php: >=5.3.9
- doctrine/data-fixtures: ~1.0
- doctrine/migrations: ~1.0
- doctrine/orm: ~2.3
- symfony/console: ~2.2|~3.0.0
- symfony/dependency-injection: ~2.2|~3.0.0
- symfony/doctrine-bridge: ~2.2|~3.0.0
Requires (Dev)
- php: >=5.5.0
- phpunit/phpunit: ~5.0
This package is not auto-updated.
Last update: 2018-04-28 12:32:32 UTC
README
此包允许你在数据库迁移期间执行 Doctrine fixtures
安装
首先使用 composer 安装包
$ composer require feeltr/fixture-loader-bundle
安装包后,在 app/AppKernel.php
中添加此包
// AppKernel::registerBundles() $bundles = array( // ... new Feeltr\Bundle\FixtureLoaderBundle\FixtureLoaderBundle(), // ... );
使用方法
通过扩展 FixtureLoaderMigration
来在迁移期间访问 fixtures 加载器
<?php namespace Application\Migrations; use Feeltr\Bundle\FixtureLoaderBundle\Component\FixtureLoaderMigration; class Version20150809022933 extends FixtureLoaderMigration { /** * @param Schema $schema */ public function up(Schema $schema) { // ... } /** * @param Schema $schema */ public function down(Schema $schema) { // ... } /** * @param Schema $schema */ public function postUp(Schema $schema) { $this->loadFixtures([ new Fixture(), ... ]); } }
此外,您还可以使用服务容器中定义的 fixtures 加载器
$fixtureLoader = $this->container->get('feeltr_fixture_loader'); $fixtureLoader->load([new Fixture()]);
最后,您可以通过在 app/config/config.yml
中的 symfony 包配置中禁用日志。默认情况下,日志是启用的。
feeltr_fixture_loader: logging: false