linkorb/haigha 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

linkorb/haigha

Composer 安装命令:

composer require linkorb/haigha

包简介

Alice fixtures for database tables

README 文档

README

Tip

Haigha has been superseeded by the brand new Hatter - similar features, still application independant, but no longer trying to use Alice in a way that it wasn't designed for.

Haigha: Alice fixtures for tables

Alice is an awesome database fixtures library. It works with Doctrine out-of-the-box, but if you don't use the Doctrine ORM, you'll need custom persisters...

This is where Haigha comes in:

Haigha lets you use Alice directly with database tables!

Features

  • Supports all standard Alice functionality (ranges, optional data, references, inheritence, etc)
  • Supports Faker data providers
  • Supports any PDO connection
  • No need to write classes, directly persist from yml to your sql database

Example fixture file

Haigha uses Alice to load fixture files, so the format is identical (Details). The only thing to keep in mind is that you use tablenames instead of classnames. Prefix your tablenames with table.. For example, if your tablename is called user, you use it like this:

table.group:
  group_random_users:
    id: 1 # This is important for version ~2.0
    name: Random users

table.user:
  random_user{0..9}:
    group_id: @group_random_users
    username: <userName()>
    firstname: <firstName()>
    lastname: <lastName()>
    password: <password()>
    email: <email()>

How to use Haigha in your application

Simply add the following to your require or require-dev section in your composer.json and run composer update:

"require": {
  "linkorb/haigha": "^2.0"
}

You can now use Haigha in your applications, or use the included command-line tool to load fixtures into your database:

Command-line usage

The haigha command-line tool knows one sub-command: fixtures:load.

The first argument is the filename of your fixture definition (yaml).

The second argument is the (optional) database url. If no database url is specified, haigha used your PDO environment variable instead.

Database URL

A full URL containing username, password, hostname and dbname. For example:

./vendor/bin/haigha fixtures:load examples/random_users.yml mysql://username:password@hostname/dbname

Just a dbname

In this case linkorb/database-manager is used for loading database connection details (server, username, password, etc) from .conf files (read project readme for more details).

In a nutshell - you must have a database_name.conf file at /share/config/database/ as described at database-manager's documentation.

./vendor/bin/haigha fixtures:load examples/random_users.yml dbname

Library usage:

You can use Haigha in your own application like this:

// Instantiate a new Alice loader
$loader = new Nelmio\Alice\Fixtures\Loader();

// Add the Haigha instantiator
$instantiator = new Haigha\TableRecordInstantiator();
$loader->addInstantiator($instantiator);

// Load (Haigha) objects from a Alice yml file
$objects = $loader->load('examples/random_users.yml');

// Instantiate the Haigha PDO persister, and pass a PDO connection
$persister = new PdoPersister($pdo);

// Persist the Haigha objects on the PDO connection
$persister->persist($objects);

Test

Customize phpunit.xml:

cp phpunit.xml.dist phpunit.xml

Run:

vendor/bin/phpunit

License

MIT (see LICENSE.md)

Brought to you by the LinkORB Engineering team


Check out our other projects at linkorb.com/engineering.

Btw, we're hiring!

linkorb/haigha 适用场景与选型建议

linkorb/haigha 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.19k 次下载、GitHub Stars 达 24, 最近一次更新时间为 2015 年 02 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「fixtures」 「alice」 「wonderland」 「march hare」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 linkorb/haigha 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 linkorb/haigha 我们能提供哪些服务?
定制开发 / 二次开发

基于 linkorb/haigha 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 24
  • Watchers: 9
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-25