定制 rbone/phactory 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rbone/phactory

最新稳定版本:1.4.0

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

Build Status

Installing

Via composer:

{
  "require-dev": {
    "rbone/phactory": "1.3.*"
  }
}

Via GIT:

git clone git://github.com/rbone/phactory.git

<?php

require 'phactory/bootstrap.php';

统计信息

  • 总下载量: 57.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 2
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-01-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固