arraypress / wp-faker
A lightweight WordPress library for generating fake data for seeding and testing
Requires
- php: >=8.3
Requires (Dev)
- phpcompatibility/phpcompatibility-wp: ^2.1
- phpunit/phpunit: ^12.0
- squizlabs/php_codesniffer: ^3.13.5
- wp-coding-standards/wpcs: ^3.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Generate plausible data for seeding a development site or a demo.
What it does
A plugin is easier to build against a hundred orders than against none, and
screenshots of an empty table sell nothing. Filling a site by hand takes an
afternoon, and 'Test Customer 1' shows every layout bug except the ones
real data has.
This generates names, emails, prices, dates and the rest, weighted so the spread looks like a real store rather than a uniform random one.
Features
- Generate names, emails, phone numbers and companies that look real
- Generate prices in minor units, so nothing has to be converted afterwards
- Pick a value with weights, so most orders are complete and a few failed
- Get a date in the past, or between two points, for a believable history
- Pull a real id from the site — a user, post or attachment that exists
- Generate many at once, for seeding a table in one go
Installation
composer require --dev arraypress/wp-faker
Quick start
Seeding a customer:
use ArrayPress\Faker\Fake; $customer = [ 'name' => Fake::name(), 'email' => Fake::email(), 'country' => Fake::country(), 'total_spent' => Fake::price(), 'status' => Fake::weighted( [ 'active' => 60, 'pending' => 20, 'inactive' => 20, ] ), 'date_created' => Fake::past_date(), ];
The weights are the useful part: a seeded table where every status is equally likely does not look like anything, and hides the layout problems a realistic spread shows up.
Requirements
- PHP 8.3 or later
- WordPress 7.1 or later
License
GPL-2.0-or-later