codesvault/wp-seeder
Composer 安装命令:
composer require codesvault/wp-seeder
包简介
Database seeder for WordPress
README 文档
README
Add demo data in the Database from terminal.
Installation
It is required to install it using composer composer install codesvault/wp-seeder.
It supports PHP >= 7.4
Uses
To create a new seeder, run below command in the terminal and provide necessary inputs.
./vendor/bin/wpseed new
It will generate /seeders directory in <plugin_root>/database directory. Don't move this directory to other location, it must be there.
In the /database/seeders folder you will have your seeder which was automatically generated, the file name will be same as the class name that you had given input.
Now change the $table property according to your table name where you want to store data. $row property is for number of rows you want to generate in the table. For generating demo data WP Seeder has build-in support of FakerPHP.
Here is an example seeder class:
class YourClassName extends WPSeeder { public $table = "cv_users"; // db table name without prefix, default is posts. public $row = 5; // number of db table row will create, default is 1. public function run() { // add data that need to be inserted in database. // array key is the column name, value is data that will be stored. return array( 'name' => $this->faker()->unique()->name(), 'email' => $this->faker()->unique()->email(), 'password' => $this->faker()->unique()->password() ); } }
If you want to create more seeders for different tables then just repeate the above process. Now just run below command in the terminal from plugin's root directory and data will be stored in the database.
`./vendor/bin/wpseed store`
.
codesvault/wp-seeder 适用场景与选型建议
codesvault/wp-seeder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 886 次下载、GitHub Stars 达 12, 最近一次更新时间为 2023 年 01 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 codesvault/wp-seeder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codesvault/wp-seeder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 886
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-11