Faker是一个为你生成假数据的PHP库。当你需要填充一个测试数据库,或为你的web应用生成测试数据时,它能派上用场。
示例代码:
<?php// require the Faker autoloaderrequire_oce '/path/to/Faker/src/autoload.php';// alteratively, use aother PSR-0 compliat autoloader (like the Symfoy2 ClassLoader for istace)// use the factory to create a Faker\Geerator istace$faker = Faker\Factory::create();// geerate data by accessig propertiesecho $faker->ame; // 'Lucy Cechtelar';echo $faker->address; // "426 Jordy Lodge // Cartwrightshire, SC 88120-6700"echo $faker->text;
评论