rbone/phactory
Composer 安装命令:
composer require rbone/phactory
包简介
A PHP library for generating data for tests
README 文档
README
(ver documentação em português)
A PHP library for creating data for tests. Designed for simplicity and extensibility.
Usage
Define factories like so:
<?php class UserPhactory { public function blueprint() { return array( 'name' => 'User #{sn}', 'activated' => true, ); } public function admin() { return array( 'isadmin' => true, ); } }
Then use them:
<?php $user = Phactory::user(); echo $user->name; // 'User 0001' echo $user->activated ? 'true' : 'false'; // 'true' $admin = Phactory::user('admin'); echo $user->name; // 'User 0002' echo $user->activated ? 'true' : 'false'; // 'true' echo $user->isadmin ? 'true' : 'false'; // 'true'
That's just the basics of what Phactory allows you to do, fixtures, dependencies and relationships are also supported, read the wiki documentation for more information.
What it doesn't do
Phactory doesn't know about your database or ORM, this is by design. Rather than trying to support every ORM out there Phactory is designed to be easily extended to support whatever it needs to. e.g. using our above UserPhactory
<?php class User {} class MyCustomBuilder extends \Phactory\Builder { protected function toObject($name, $values) { $object = new $name; foreach ($values as $key => $value) { $object->$key = $value; } return $object; } } Phactory::builder(new MyCustomBuilder); $user = Phactory::user(); echo get_class($user); // 'User'
Status
Up to v1.3.0
Installing
Via composer:
{ "require-dev": { "rbone/phactory": "1.3.*" } }
Via GIT:
git clone git://github.com/rbone/phactory.git
<?php
require 'phactory/bootstrap.php';
rbone/phactory 适用场景与选型建议
rbone/phactory 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 57.58k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2013 年 01 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「data」 「test」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rbone/phactory 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rbone/phactory 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rbone/phactory 相关的其它包
同方向 / 同关键字的高下载量 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
Specification-oriented BDD helpers for PHPUnit
Data provider for yii2
统计信息
- 总下载量: 57.58k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 11
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-01-03