Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codesvault/wp-seeder
Database seeder for WordPress
https://github.com/codesvault/wp-seeder
database mysql mysql-database seeder seeders wordpress wordpress-php-library
Last synced: 3 months ago
JSON representation
Database seeder for WordPress
- Host: GitHub
- URL: https://github.com/codesvault/wp-seeder
- Owner: CodesVault
- License: mit
- Created: 2023-01-08T08:34:42.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-16T21:06:05.000Z (over 1 year ago)
- Last Synced: 2024-11-07T11:02:20.591Z (3 months ago)
- Topics: database, mysql, mysql-database, seeder, seeders, wordpress, wordpress-php-library
- Language: PHP
- Homepage: https://packagist.org/packages/codesvault/wp-seeder
- Size: 56.1 MB
- Stars: 12
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# WP Seeder
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.1**
## Uses
To create a new seeder, run `./vendor/bin/wpseed new` and provide necessary inputs.
It will generate `/seeders` directory in `/database` directory. Don't move this directory to other location, it must be here.
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](https://fakerphp.github.io/).
```php
class yourClassName extends WPSeeder
{
public $table = "cv_users"; // db table name without prefix, default is posts.
public $row = 5000; // 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 `./vendor/bin/wpseed store` in the terminal and data will be stored in the database.
.