nelmio/alice
Composer 安装命令:
composer require nelmio/alice
包简介
Expressive fixtures generator
README 文档
README
Alice - Expressive fixtures generator
Relying on FakerPHP/Faker, Alice allows you to create a ton of fixtures/fake data for use while developing or testing your project. It gives you a few essential tools to make it very easy to generate complex data with constraints in a readable and easy to edit way, so that everyone on your team can tweak the fixtures if needed.
Warning: this doc is for alice 3.0. If you want to check the documentation for 2.x, follow this link.
2.x is in maintenance mode: PRs are accepted, but no active development is done on it by the maintainers any longer.
Table of Contents
- Installation
- Example
- Getting Started
- Complete Reference
- Handling Relations
- Keep Your Fixtures Dry
- Customize Data Generation
- Advanced Guide
- Third-party libraries
- Contribute
- Backward Compatibility Promise (BCP)
- Upgrade
Installation
This is installable via Composer as nelmio/alice:
composer require --dev nelmio/alice
Example
Here is a complete example of entity declaration:
Nelmio\Entity\User: user{1..10}: username: '<username()>' fullname: '<firstName()> <lastName()>' birthDate: '<date_create()>' email: '<email()>' favoriteNumber: '50%? <numberBetween(1, 200)>' Nelmio\Entity\Group: group1: name: Admins owner: '@user1' members: '<numberBetween(1, 10)>x @user*' created: '<dateTimeBetween("-200 days", "now")>' updated: '<dateTimeBetween($created, "now")>'
You can then load them easily with:
$loader = new Nelmio\Alice\Loader\NativeLoader(); $objectSet = $loader->loadFile(__DIR__.'/fixtures.yml');
Or load an array right away:
$loader = new Nelmio\Alice\Loader\NativeLoader(); $objectSet = $loader->loadData([ \Nelmio\Entity\User::class => [ 'user{1..10}' => [ 'username' => '<username()>', 'fullname' => '<firstName()> <lastName()>', 'birthDate' => '<date_create()>', 'email' => '<email()>', 'favoriteNumber' => '50%? <numberBetween(1, 200)>', ], ], \Nelmio\Entity\Group::class => [ 'group1' => [ 'name' => 'Admins', 'owner' => '@user1', 'members' => '<numberBetween(1, 10)>x @user*', 'created' => '<dateTimeBetween("-200 days", "now")>', 'updated' => '<dateTimeBetween($created, "now")>', ], ], ]);
For more information, refer to the documentation.
Third-party libraries
Framework Agnostic
Symfony
Nette
WordPress
Zend Framework 2:
Contribute
Check the contribution guide.
Backward Compatibility Promise (BCP)
The policy is for the major part following the same as Symfony's one with a few changes or highlights:
- Code marked with
@privateor@internalare excluded from the BCP Nelmio\Alice\Loader\NativeLoaderis excluded from the BCP: as it is the no DIC solution, registring a new service may require a new method, in which case your code may break if you have already declared that method. To avoid that, please beware of the naming of your methods to avoid any conflicts.
Upgrade
Check the upgrade guide.
nelmio/alice 适用场景与选型建议
nelmio/alice 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 44.88M 次下载、GitHub Stars 达 2.54k, 最近一次更新时间为 2012 年 10 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「faker」 「data」 「test」 「Fixture」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nelmio/alice 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nelmio/alice 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nelmio/alice 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Testing Suite For Lumen like Laravel does.
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.
Additional plugin for fakerphp/faker that allows you to generate a random animal
统计信息
- 总下载量: 44.88M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2566
- 点击次数: 44
- 依赖项目数: 166
- 推荐数: 4
其他信息
- 授权协议: MIT
- 更新时间: 2012-10-29
