ravage84/cakephp-fake-seeder
Composer 安装命令:
composer require ravage84/cakephp-fake-seeder
包简介
A shell to seed your database with fake and/or fixed data.
README 文档
README
A CakePHP shell to seed your database with fake and/or fixed data.
Uses Faker to generate the fake data. Uses shell tasks for implementing specific seeders. Organizes logical groups of seeders in custom seeder shells/suites.
Why should I use it?
You are wondering why you should use this plugin instead of using Faker directly or creating fake data on your own?
This plugin...
- keeps you from doing the repetitive work (DRY)
- provides you three working modes (manual faking to fully automatic guessing)
- helps you to stick to conventions, by following CakePHP's "Convention over Configuration" principle
- still provides you flexible configuration
- reduces documentation needs
- is properly covered by unit tests
- is easy to learn
- is extensible
Installation
Requirements
- PHP >= 5.4
- CakePHP 2.x (tested with 2.6.2, 2.7.3)
Installation via composer
composer require ravage84/cakephp-fake-seeder
Installation alternatives
Refer to the CakePHP CookBook section How To Install Plugins.
CakePHP Version Support
This plugin only supports CakePHP 2.x.
Versioning
The releases of this plugin are versioned using SemVer.
Configuration
Set the configuration key FakeSeeder.seedable to true, by adding
Configure::write('FakeSeeder.seedable', true); to your boostrap code.
How to use
After installing and configuring the plugin, you can invoke the shell
by executing php Console/cake.php FakeSeeder.seeder -h.
Welcome to CakePHP v2.6.2 Console
---------------------------------------------------------------
App : app
Path: D:\dev\xampp\htdocs\cate\app\
---------------------------------------------------------------
A shell to seed your database with fake and/or fixed data.
Uses Faker to generate the fake data.
Uses shell tasks for implementing specific seeders.
Organizes logical groups of seeders in custom seeder shells/suites.
Usage:
cake fake_seeder.seeder [options] [<model>]
Options:
--help, -h Display this help.
--verbose, -v Enable verbose output.
--quiet, -q Enable quiet output.
--mode, -m The seeding mode.
'manual' = No Field formatters are guessed.
'auto' = All field formatters are guessed.
'mixed' = Only missing field formatters are guessed.
(choices: manual|auto|mixed)
--locale, -l The locale to use for Faker.
--records, -r The amount of records to seed.
--validate Whether or not to validate when saving the seeding
data. (choices: first|1|)
--seed, -s Set the seed number for Faker to use.
--no-truncate Prevents that the model gets truncated before
seeding.
Arguments:
model The name of a seeder shell task without 'SeederTask' suffix.
For example 'Article' for 'ArticleSeederTask'.
Alternatively the name of a model.
It will try to guess the field formatters then.
(optional)
All shell options can be set through:
1. CLI parameter, e.g. "--records"
2. The seeder specific configuration, e.g. "FakeSeeder.Article.records"
3. The general seeder configuration, e.g "FakeSeeder.records"
4. The seeder shell task class properties, e.g. "$_records"
The values are checked in that order. The first value found is taken.
If no value is set, it will fall back to an optional default value.
When no seeders are set (e.g. in a custom seeder suite) and if called
without arguments, it will prompt to execute one of the seeder shell
tasks available.
- See ExampleSeederShell.php for an example how to create a custom seeder shell.
- See ExampleSeederTask.php for an example how to create a custom seeder task.
Contributing
See CONTRIBUTING.md
Changelog
See CHANGELOG.md
TODOs
- Improve Documentation
- Simplify integration of 3rd party data provider
- Implement seeder shell task baking
- Check possibility to use code for TestFixtures, like gourmet/faker
License
This plugin is licensed under the MIT License.
Attribution
This project was inspired by the works of others, such as:
ravage84/cakephp-fake-seeder 适用场景与选型建议
ravage84/cakephp-fake-seeder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.52k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2015 年 08 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「faker」 「fixtures」 「data」 「plugin」 「cakephp」 「seeder」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ravage84/cakephp-fake-seeder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ravage84/cakephp-fake-seeder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ravage84/cakephp-fake-seeder 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Testing object factory for PHP
Testing object factory for PHP
Adds the EDTF data type to Wikibase
Plugin to compare fixtures with live DB tables
A simple library that allows transform any kind of data to native php data or whatever
统计信息
- 总下载量: 4.52k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-30