Faker 是一个PHP填充假数据的库,可以往数据库里填写大量假数据用于测试使用。
安装
composer require fzaninotto/faker
include 'vendor/autoload.php'; $data = []; $faker = Faker\Factory::create('zh_CN'); for ($i = 0; $i < 200; $i++) { $data[$i]['userName'] = $faker->userName; $data[$i]['name'] = $faker->name; $data[$i]['email'] = $faker->email; $data[$i]['phoneNumber'] = $faker->phoneNumber; $data[$i]['address'] = $faker->address; $data[$i]['ipv4'] = $faker->ipv4; } echo '<pre>'; print_r($data);
github: https://github.com/fzaninotto/Faker