arraypress/wp-faker
Composer 安装命令:
composer require --dev arraypress/wp-faker
包简介
A lightweight WordPress library for generating fake data for seeding and testing
README 文档
README
A lightweight WordPress library for generating fake data for seeding and testing. Built for e-commerce plugins and admin table demos.
Installation
composer require arraypress/wp-faker
Quick Start
use ArrayPress\Faker\Fake; // Generate a customer $customer = [ 'name' => Fake::name(), // "Sarah Johnson" 'email' => Fake::email(), // "sarah.johnson@company.com" 'phone' => Fake::phone(), // "+1 555-234-5678" 'company' => Fake::company(), // "Johnson Technologies" 'country' => Fake::country(), // "us" 'status' => Fake::weighted( [ 'active' => 60, 'pending' => 20, 'inactive' => 20 ] ), 'total_spent' => Fake::price(), // 4999 (cents) 'order_count' => Fake::number( 1, 50 ), 'date_created' => Fake::past_date(), // "2024-03-15 14:22:09" ];
API Reference
People
Fake::first_name(); // "Sarah" Fake::last_name(); // "Johnson" Fake::name(); // "Sarah Johnson" Fake::email(); // "sarah.johnson@company.com" Fake::email( 'Sarah', 'Johnson' ); // Consistent email from name Fake::phone(); // "+1 555-234-5678"
Companies
Fake::company(); // "Johnson Technologies"
Commerce
Fake::price(); // 4999 (cents, $1–$5,000) Fake::price( 500, 10000 ); // Custom range in cents Fake::sku(); // "PRD-45821" Fake::product_name(); // "Premium Widget"
Location
Fake::country(); // "us" (lowercase ISO alpha-2)
Dates
Fake::date_between( '-2 years', 'now' ); // "2024-03-15 14:22:09" Fake::date_between( '-30 days', 'now' ); // Recent date Fake::past_date(); // Random date in last 2 years Fake::past_date( 365 ); // Random date in last year Fake::past_date( 30, 'Y-m-d' ); // Date-only format
Text
Fake::sentence(); // "The customer process would update first." Fake::sentence( 8 ); // Exactly 8 words Fake::paragraph(); // 3-6 random sentences Fake::paragraph( 4 ); // Exactly 4 sentences
WordPress
Fake::user_id(); // 42 (random existing user) Fake::user_id( 'subscriber' ); // Random subscriber Fake::post_id(); // 156 (random published post) Fake::post_id( 'product' ); // Random product post Fake::attachment_id(); // 89 (random attachment) Fake::attachment_id( 'image' ); // Random image attachment Fake::term_id(); // 12 (random category) Fake::term_id( 'post_tag' ); // Random tag
All WordPress methods return null if no matching items exist.
Utilities
// Weighted random selection Fake::weighted( [ 'active' => 60, 'pending' => 20, 'inactive' => 20, ] ); // "active" (60% of the time) // Generate multiple items Fake::many( fn() => Fake::name(), 10 ); // Array of 10 names // Random number Fake::number( 1, 100 ); // Random integer // Random boolean Fake::boolean(); // true/false (50/50) Fake::boolean( 80 ); // true 80% of the time // Pick from any array Fake::random_element( [ 'a', 'b', 'c' ] ); // Random element
Seeding Example
use ArrayPress\Faker\Fake; // Seed 100 customers for ( $i = 0; $i < 100; $i++ ) { $first = Fake::first_name(); $last = Fake::last_name(); $query->add_item( [ 'name' => $first . ' ' . $last, 'email' => Fake::email( $first, $last ), 'phone' => Fake::phone(), 'company' => Fake::company(), 'country' => Fake::country(), 'status' => Fake::weighted( [ 'active' => 60, 'pending' => 20, 'inactive' => 20 ] ), 'total_spent' => Fake::price( 5000, 500000 ), 'order_count' => Fake::number( 1, 50 ), 'notes' => Fake::boolean( 70 ) ? Fake::sentence() : '', 'date_created' => Fake::past_date(), ] ); }
Requirements
- PHP 7.4 or later
- WordPress 6.2 or later (only for the WordPress methods)
License
GPL-2.0-or-later
arraypress/wp-faker 适用场景与选型建议
arraypress/wp-faker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「faker」 「testing」 「wordpress」 「mock」 「seed」 「dummy-data」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 arraypress/wp-faker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 arraypress/wp-faker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 arraypress/wp-faker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Testing Suite For Lumen like Laravel does.
Symfony bundle to manage fixtures with Alice and Faker.
Additional plugin for fakerphp/faker that allows you to generate a random animal
The PHP SDK for Checkmango
Faker Japanese is a Faker provider that generates fake Japanese related data for you.
A model factory package for Laravel 4 with expressive API for creating custom tailored dummy objects
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2026-02-04