承接 codesvault/wp-seeder 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

codesvault/wp-seeder

最新稳定版本:1.2.0

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`

.

统计信息

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

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-11