ravage84/cakephp-fake-seeder

一个用于将假数据和/或固定数据注入数据库的壳。

安装量: 4,510

依赖项: 0

建议者: 0

安全: 0

星级: 10

关注者: 1

分支: 8

开放问题: 3

类型:cakephp-plugin

0.1.0 2015-08-31 15:52 UTC

This package is auto-updated.

Last update: 2024-09-12 03:38:41 UTC


README

Travis-CI Build Status Coverage Status Scrutinizer Code Quality Total Downloads Latest Stable Version

一个用于将假数据和/或固定数据注入 CakePHP 数据库的壳。

使用 Faker 生成假数据。使用壳任务实现特定的种子器。在自定义种子壳/套件中组织种子器的逻辑组。

为什么我要使用它?

你在想为什么你应该使用这个插件而不是直接使用 Faker 或者自己创建假数据?

这个插件...

  • 让你避免重复工作(DRY)
  • 提供三种工作模式(从手动伪造到完全自动猜测)
  • 帮助你遵循约定,通过遵循 CakePHP 的“约定优于配置”原则
  • 仍然提供灵活的配置
  • 减少文档需求
  • 经过适当的单元测试
  • 易于学习
  • 可扩展

安装

要求

  • PHP >= 5.4
  • CakePHP 2.x(测试过 2.6.2,2.7.3)

通过 composer 安装

composer require ravage84/cakephp-fake-seeder

安装替代方案

参考 CakePHP CookBook 中的 如何安装插件 部分。

CakePHP 版本支持

此插件仅支持 CakePHP 2.x。

版本控制

此插件的版本使用 SemVer 进行版本控制。

配置

将配置键 FakeSeeder.seedable 设置为 true,通过在您的引导代码中添加 Configure::write('FakeSeeder.seedable', true); 来完成。

如何使用

安装和配置插件后,您可以通过执行 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.

贡献

请参阅 CONTRIBUTING.md

变更日志

请参阅 CHANGELOG.md

待办事项

  • 改进文档
  • 简化第三方数据提供程序的集成
  • 实现种子壳任务烘焙
  • 检查使用代码为 TestFixtures 的可能性,如 gourmet/faker

许可证

此插件采用 MIT 许可证

归属

此项目受到其他人的启发,例如