it-blaster / fixtures-bundle
Propel fixtures 的 Symfony2 扩展包
Requires
- propel/propel: ~2.0@dev
- propel/propel-bundle: >=1.4
- propel/propel1: ~1.6
- symfony/symfony: >=2.2
This package is not auto-updated.
Last update: 2024-09-14 16:39:52 UTC
README
Symfony2 扩展包用于 Propel fixtures。由于普通的 propel:fixtures:load
任务会抛出错误 Attempted to call method "getPeerClassname" on class "Propel\Runtime\Map\TableMap".
,为了修复这个问题,需要重写任务和 DataFixtures/Loader
文件夹中的文件。所有这些都被放到了一个独立的包 FixturesBundle 中。
安装
将 ItBlasterFixturesBundle 添加到 composer.json
{ "require": { "it-blaster/fixtures-bundle": "dev-master" }, }
现在运行 composer 命令下载包
$ php composer.phar update it-blaster/fixtures-bundle
composer 会将包安装到项目文件夹 vendor/it-blaster/fixtures-bundle
中。
接下来在 AppKernel.php
核心中连接包
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new ItBlaster\FixturesBundle\ItBlasterFixturesBundle(), ); }
导出 - 创建 fixtures
创建 fixtures 的任务可以通过命令 php app/console it-blaster:fixtures:dump
执行。fixtures 文件将被创建在 app/propel/fixtures
中。
加载 - 从 fixtures 加载到数据库
加载 fixtures 的任务可以通过命令 php app/console it-blaster:fixtures:load @AppMainBundle
执行,其中 @AppMainBundle 是包含 fixtures 文件的包名。默认情况下,fixtures 文件将从 app/propel/fixtures
文件夹中获取。
鸣谢
It-Blaster it-blaster@yandex.ru