Download the PHP package motivast/wp-cli-seed-command without Composer
On this page you can find all versions of the php package motivast/wp-cli-seed-command. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download motivast/wp-cli-seed-command
More information about motivast/wp-cli-seed-command
Files in motivast/wp-cli-seed-command
Package wp-cli-seed-command
Short Description WP CLI Seed Command is an extension for WP-CLI to seed database with sample data
License MIT
Homepage https://github.com/motivast/wp-cli-seed-command
Informations about the package wp-cli-seed-command
WP CLI Seed Command
WP CLI Seed Command is an extension for WP-CLI to seed database with sample data.
Why?
Working with advanced WordPress project require to provide test data for other developers or testing scripts. Working with MySQL dumps or exported data has a couple of disadvantages. Data from files like import file or MySQL dump are static you can not quickly scale from 10 random to 100 random posts, also you can not import local media files.
This command-line tools aim to solve these problems. You can write your seeds in PHP which gives you unlimited possibilities.
Installation
You can install WP CLI Seed Command like any other WP-CLI extension
If you want to install WP CLI Seed Command locally you can use composer in your project root directory
Getting started
WP CLI Seed is providing two commands wp seed
for seeding database with data and wp scaffold seeder
to quickly create new seeders. To create the main seeder the following command.
This command will create a Seeder.php
file in the seeds
directory with the following content.
Everything inside run
method will be executed during seeding database. Inside it you can add any PHP code including WordPress functions. Let's change some WordPress options and add basic pages.
Now you can import your seeds executing following command.
Your WordPress options should change and new pages should be created.
Splitting files
When your project will grow you might want to split seeds into multiple files. Based on the example above you can split this into two files. Create 'Options.php' and 'Pages.php' seeders.
Newlly created seeders have to be included and executed in your main Seeder.php
file. Change your already existing Seeder.php
to handle new seeders.
Contribute
Please make sure to read the Contribution guide before making a pull request.
Thank you to all the people who already contributed to WP-CLI Seed Command!
License
The project is licensed under the MIT.
Copyright (c) 2019-present, Motivast