faker 生成验证数据

最后更新于:2022-04-02 02:24:03

[TOC] ## 安装 `composer req fzaninotto/faker ` ## 示例 ### 简单示例 ``` $faker = Faker\Factory::create('zh_CN'); echo $faker->name.PHP_EOL; // 阎文彬 echo $faker->city.PHP_EOL; // 南京 echo $faker->email.PHP_EOL; // tenetur.libero@yahoo.com ``` ### 伪造用户名 ``` $faker = Faker\Factory::create('zh_CN'); echo $faker->name . PHP_EOL; // 苗娟 echo $faker->address.PHP_EOL ; //哈尔滨高明区 ``` ### 伪造颜色 ``` $faker = Faker\Factory::create('zh_CN'); echo $faker->hexcolor . "\n"; // #dcf422 echo $faker->rgbcolor . "\n"; // 208,156,194 dump($faker->rgbColorAsArray); //array:3 [ // 0 => 208 // 1 => 109 // 2 => 68 //] echo $faker->rgbCssColor . "\n"; // rgb(1,122,206) echo $faker->safeColorName . "\n"; // 鲜绿色 echo $faker->colorName . "\n"; // 银色 ``` ### 伪造手机号 ``` $faker = Faker\Factory::create('zh_CN'); echo $faker->phoneNumber.PHP_EOL; // 17034092720 ``` ### 互联网相关数据 ``` $faker = Faker\Factory::create('zh_CN'); echo $faker->email . "\n"; // doloribus_non@hotmail.com echo $faker->userName . "\n"; // nnon echo $faker->password . "\n"; // ME!!UZJ^0Bvp echo $faker->url . "\n"; // http://www.zhang.com/quod-rerum-rerum-ex-atque-qui-delectus echo $faker->slug . "\n"; // eius-impedit-similique-harum-et-aut echo $faker->ipv4 . "\n"; // 30.178.126.218 echo $faker->localIpv4 . "\n"; // 10.193.39.235 echo $faker->ipv6 . "\n"; // 2f1:25b6:d118:9b61:fa01:db07:980a:855e echo $faker->macAddress . "\n"; // 62:0D:86:86:2C:76 ```
';