theofidry/alice-data-fixtures
Composer 安装命令:
composer require theofidry/alice-data-fixtures
包简介
Nelmio alice extension to persist the loaded fixtures.
README 文档
README
Alice 3.x no longer ships with a persistence layer, so this library provides one!
Supports:
- Symfony 7.4+
- Doctrine ORM 3.3+
- Doctrine ODM 5.1+
- Doctrine PHPCR 2.0+
- Eloquent 12.0+
Documentation
Configuration
The full configuration reference is:
# app/config/config.yml # Default config fidry_alice_data_fixtures: default_purge_mode: ~ # default is "delete" but you can change it to "truncate" or "no_purge" db_drivers: doctrine_orm: ~ doctrine_mongodb_odm: ~ doctrine_phpcr_odm: ~ eloquent_orm: ~
For each driver, if the appropriate bundle is detected, e.g. DoctrineORMBundle for Doctrine and WouterJEloquentBundle
for Eloquent, the services related to those driver will be enabled. If you want to skip those checks you can turn
a specific driver to true instead. If you want to disable a specific driver, simply force the value false instead.
Basic usage
Create a fixture file in src/AppBundle/Resources/fixtures:
# src/AppBundle/Resources/fixtures/dummy.yml AppBundle\Entity\Dummy: dummy_{1..10}: name: <name()> related_dummy: '@related_dummy*'
# src/AppBundle/Resources/fixtures/related_dummy.yml AppBundle\Entity\RelatedDummy: related_dummy_{1..10}: name: <name()>
Then you can load those files using a LoaderInterface:
<?php $files = [ 'path/to/src/AppBundle/Resources/fixtures/dummy.yml', 'path/to/src/AppBundle/Resources/fixtures/related_dummy.yml', ]; // Choose your loader $loader = $container->get('fidry_alice_data_fixtures.loader.doctrine'); // For Doctrine ORM $loader = $container->get('fidry_alice_data_fixtures.loader.doctrine_mongodb'); // For Doctrine MongoDB ODM $loader = $container->get('fidry_alice_data_fixtures.loader.doctrine_phpcr'); // For Doctrine PHPCR $loader = $container->get('fidry_alice_data_fixtures.loader.eloquent'); // For Eloquent ORM // Purge the objects, create PHP objects from the fixture files and persist them $objects = $loader->load($files); // $objects is now an array of persisted `Dummy` and `RelatedDummy`
Warning: loading the objects does not trigger a clear(). This means if
you are relying on some Doctrine life-cycle events in your tests, some may not
be triggered as expected. See #84 For more information.
Advanced Usage
Check the advance usage entry.
Contributing
Clone the project
To launch Docker containers for databases, run make start_databases
Run tests with make test.
To stop containers for databases, run make stop_databases
theofidry/alice-data-fixtures 适用场景与选型建议
theofidry/alice-data-fixtures 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29.98M 次下载、GitHub Stars 达 323, 最近一次更新时间为 2016 年 09 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「orm」 「faker」 「data」 「Fixture」 「tests」 「alice」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 theofidry/alice-data-fixtures 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 theofidry/alice-data-fixtures 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 theofidry/alice-data-fixtures 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Kinikit - PHP Application development framework MVC component
PHP Database ORM for Symfony1. Do NOT use for new projects: please move to a newest Symfony release and Doctrine2
Adds the EDTF data type to Wikibase
A simple library that allows transform any kind of data to native php data or whatever
Symfony bundle to manage fixtures with Alice and Faker.
统计信息
- 总下载量: 29.98M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 324
- 点击次数: 43
- 依赖项目数: 75
- 推荐数: 4
其他信息
- 授权协议: MIT
- 更新时间: 2016-09-12