定制 lulco/populator 二次开发

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

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

lulco/populator

Composer 安装命令:

composer require lulco/populator

包简介

Database fake data populator for PHP

README 文档

README

Allows populate fake data to your database

PHP unit PHPStan level PHP static analysis SensioLabsInsight Latest Stable Version Total Downloads PHP 7 supported

The best feature of this library is AutomaticPopulatorCommand which populates data based on full database structure. It analyses database table tree and creates items for each table - leaves first.

// file bin/command.php

$database = new Populator\Database\Database('db_name', 'mysql:dbname=db_name;host=db_host', 'db_user', 'db_password');
$populator = new Populator\Command\AutomaticPopulatorCommand($database, ['phoenix_log', 'phinxlog', 'migration_log', 'versions', 'api_logs', 'api_tokens'], true, $columnNameAndTypeCallbacks);

$application = new Application();
$application->add($populator);
$application->run();

Run:

php bin/command.php populator:populate

With this setup, AutomaticPopulatorCommand will create 5 items in all leaf-tables, than 25 for 2nd level, and 125 for all next levels. It can be changed by parameters $countBase and $maxCountPerTable of AutomaticPopulatorCommand.

You can also use AutomaticPopulator which allows you to create fake data for one table based on its structure or column names.

Create file e.g. bin/command.php as shown below (or add PopulatorCommand to existing Symfony console application):

// file bin/command.php

$application = new Symfony\Component\Console\Application();
$populator = new Populator\Command\PopulatorCommand();
$populator->addDatabase(new Populator\Database\Database('db_name', 'mysql:dbname=db_name;host=db_host', 'db_user', 'db_password'));

$table1Populator = new Populator\Populator\AutomaticPopulator('table_1', 50);
$populator->addPopulator($table1Populator);

$application->add($populator);
$application->run();

This setup will populate 50 fake rows for database table with name table_1 after executing this command:

php bin/command.php populator:populate

统计信息

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

GitHub 信息

  • Stars: 9
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固