# Faker #
Faker is a PHP library that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in your persistence to stress test it, or anonymize data taken from a production service, Faker is for you.
Faker is heavily inspired by Perl's [Data::Faker](http://search.cpan.org/~jasonk/Data-Faker-0.07/), and by ruby's [Faker](http://faker.rubyforge.org/).
Faker requires PHP >= 5.3.3.
[![Monthly Downloads](https://poser.pugx.org/fzaninotto/faker/d/monthly.png)](https://packagist.org/packages/fzaninotto/faker) [![Build Status](https://secure.travis-ci.org/fzaninotto/Faker.png)](http://travis-ci.org/fzaninotto/Faker) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/eceb78a9-38d4-4ad5-8b6b-b52f323e3549/mini.png)](https://insight.sensiolabs.com/projects/eceb78a9-38d4-4ad5-8b6b-b52f323e3549)
## Basic Usage
Use `Faker\Factory::create()` to create and initialize a faker generator, which can generate data by accessing properties named after the type of data you want.
```php
<?php
// require the Faker autoloader
require_once '/path/to/Faker/src/autoload.php';
// alternatively, use another PSR-0 compliant autoloader (like the Symfony2 ClassLoader for instance)
// use the factory to create a Faker\Generator instance
$faker = Faker\Factory::create();
// generate data by accessing properties
echo $faker->name;
// 'Lucy Cechtelar';
echo $faker->address;
// "426 Jordy Lodge
// Cartwrightshire, SC 88120-6700"
echo $faker->text;
// Sint velit eveniet. Rerum atque repellat voluptatem quia rerum. Numquam excepturi
// beatae sint laudantium consequatur. Magni occaecati itaque sint et sit tempore. Nesciunt
// amet quidem. Iusto deleniti cum autem ad quia aperiam.
// A consectetur quos aliquam. In iste aliquid et aut similique suscipit. Consequatur qui
// quaerat iste minus hic expedita. Consequuntur error magni et laboriosam. Aut aspernatur
// voluptatem sit aliquam. Dolores voluptatum est.
// Aut molestias et maxime. Fugit autem facilis quos vero. Eius quibusdam possimus est.
// Ea quaerat et quisquam. Deleniti sunt quam. Adipisci consequatur id in occaecati.
// Et sint et. Ut ducimus quod nemo ab voluptatum.
```
Even if this example shows a property access, each call to `$faker->name` yields a different (random) result. This is because Faker uses `__get()` magic, and forwards `Faker\Generator->$property` calls to `Faker\Generator->format($property)`.
```php
<?php
for ($i=0; $i < 10; $i++) {
echo $faker->name, "\n";
}
// Adaline Reichel
// Dr. Santa Prosacco DVM
// Noemy Vandervort V
// Lexi O'Conner
// Gracie Weber
// Roscoe Johns
// Emmett Lebsack
// Keegan Thiel
// Wellington Koelpin II
// Ms. Karley Kiehn V
```
**Tip**: For a quick generation of fake data, you can also use Faker as a command line tool thanks to [faker-cli](https://github.com/bit3/faker-cli).
## Formatters
Each of the generator properties (like `name`, `address`, and `lorem`) are called "formatters". A faker generator has many of them, packaged in "providers". Here is a list of the bundled formatters in the default locale.
### `Faker\Provider\Base`
randomDigit // 7
randomDigitNotNull // 5
randomNumber($nbDigits = NULL) // 79907610
randomFloat($nbMaxDecimals = NULL, $min = 0, $max = NULL) // 48.8932
numberBetween($min = 1000, $max = 9000) // 8567
randomLetter // 'b'
randomElements($array = array ('a','b','c'), $count = 1) // array('c')
randomElement($array = array ('a','b','c')) // 'b'
numerify($string = '###') // '609'
lexify($string = '????') // 'wgts'
bothify($string = '## ??') // '42 jz'
### `Faker\Provider\Lorem`
word // 'aut'
words($nb = 3) // array('porro', 'sed', 'magni')
sentence($nbWords = 6) // 'Sit vitae voluptas sint non voluptates.'
sentences($nb = 3) // array('Optio quos qui illo error.', 'Laborum vero a officia id corporis.', 'Saepe provident esse hic eligendi.')
paragraph($nbSentences = 3) // 'Ut ab voluptas sed a nam. Sint autem inventore aut officia aut aut blanditiis. Ducimus eos odit amet et est ut eum.'
paragraphs($nb = 3) // array('Quidem ut sunt et quidem est accusamus aut. Fuga est placeat rerum ut. Enim ex eveniet facere sunt.', 'Aut nam et eum architecto fugit repellendus illo. Qui ex esse veritatis.', 'Possimus omnis aut incidunt sunt. Asperiores incidunt iure sequi cum culpa rem. Rerum exercitationem est rem.')
text($maxNbChars = 200) // 'Fuga totam reiciendis qui architecto fugiat nemo. Consequatur recusandae qui cupiditate eos quod.'
### `Faker\Provider\en_US\Person`
title($gender = null|'male'|'female') // 'Ms.'
titleMale // 'Mr.'
titleFemale // 'Ms.'
suffix // 'Jr.'
name($gender = null|'male'|'female') // 'Dr. Zane Stroman'
firstName($gender = null|'male'|'female') // 'Maynard'
firstNameMale // 'Maynard'
firstNameFemale // 'Rachel'
lastName // 'Zulauf'
### `Faker\Provider\en_US\Address`
cityPrefix // 'Lake'
secondaryAddress // 'Suite 961'
state // 'NewMexico'
stateAbbr // 'OH'
citySuffix // 'borough'
streetSuffix // 'Keys'
buildingNumber // '484'
city // 'West Judge'
streetName // 'Keegan Trail'
streetAddress // '439 Karley Loaf Suite 897'
postcode // '17916'
address // '8888 Cummings Vista Apt. 101, Susanbury, NY 95473'
country // 'Falkland Islands (Malvinas)'
latitude // '77.147489'
longitude // '86.211205'
### `Faker\Provider\en_US\PhoneNumber`
phoneNumber // '132-149-0269x3767'
### `Faker\Provider\en_US\Company`
catchPhrase // 'Monitored regional contingency'
bs // 'e-enable robust architectures'
company // 'Bogan-Treutel'
companySuffix // 'and Sons'
### `Faker\Provider\en_US\Text`
realText($maxNbChars = 200, $indexSize = 2) // "And yet I wish you could manage it?) 'And what are they made of?' Alice asked in a shrill, passionate voice. 'Would YOU like cats if you were never even spoke to Time!' 'Perhaps not,' Alice replied."
### `Faker\Provider\DateTime`
unixTime($max = 'now') // 58781813
dateTime($max = 'now') // DateTime('2008-04-25 08:37:17')
dateTimeAD($max = 'now') // DateTime('1800-04-29 20:38:49')
iso8601($max = 'now') // '1978-12-09T10:10:29+0000'
date($format = 'Y-m-d', $max = 'now') // '1979-06-09'
time($format = 'H:i:s', $max = 'now') // '20:49:42'
dateTimeBetween($startDate = '-30 years', $endDate = 'now') // DateTime('2003-03-15 02:00:49')
dateTimeThisCentury($max = 'now') // DateTime('1915-05-30 19:28:21')
dateTimeThisDecade($max = 'now') // DateTime('2007-05-29 22:30:48')
dateTimeThisYear($max = 'now') // DateTime('2011-02-27 20:52:14')
dateTimeThisMonth($max = 'now') // DateTime('2011-10-23 13:46:23')
amPm($max = 'now') // 'pm'
dayOfMonth($max = 'now') // '04'
dayOfWeek($max = 'now') // 'Friday'
month($max = 'now') // '06'
monthName($max = 'now') // 'January'
year($max = 'now') // '1993'
century // 'VI'
timezone // 'Europe/Paris'
### `Faker\Provider\Internet`
email // '[email protected]'
safeEmail // '[email protected]'
freeEmail
没有合适的资源?快使用搜索试试~ 我知道了~
基于PHP的心雨电台在线音乐系统php版源码.zip
共2000个文件
js:701个
html:281个
png:222个
需积分: 5 0 下载量 75 浏览量
2024-01-04
23:14:30
上传
评论
收藏 27.3MB ZIP 举报
温馨提示
基于PHP的心雨电台在线音乐系统php版源码
资源推荐
资源详情
资源评论
收起资源包目录
基于PHP的心雨电台在线音乐系统php版源码.zip (2000个子文件)
main.php.bak 654B
yii.bat 515B
bootstrap.css 129KB
bootstrap.css 129KB
bootstrap.min.css 125KB
bootstrap.min.css 107KB
bootstrap.min.css 107KB
bootstrap.min.css 107KB
jquery-ui-1.10.0.custom.css 60KB
style.css 52KB
ueditor.css 45KB
font-awesome-ie7.min.css 37KB
mobiscroll.custom-2.5.2.min.css 36KB
excite-bike.css 34KB
ueditor.min.css 34KB
docs.css 29KB
fullcalendar.css 22KB
font-awesome.min.css 22KB
video-js.css 22KB
default.css 21KB
bootstrap-theme.css 21KB
bootstrap-theme.css 21KB
docs.min.css 20KB
image.css 19KB
bootstrap-theme.min.css 18KB
bootstrap-theme.min.css 18KB
bootstrap-theme.min.css 18KB
bootstrap-theme.min.css 18KB
umeditor.css 18KB
style.css 16KB
video.css 15KB
attachment.css 15KB
style.css 14KB
umeditor.min.css 14KB
mobiscroll.animation-2.5.2.css 13KB
base.css 13KB
video-js.min.css 11KB
bootstrap-datetimepicker.min.css 11KB
fullcalendar.min.css 10KB
fullcalendar.min.css 10KB
mobiscroll.wp-2.5.2.css 10KB
mathquill.css 9KB
layout.css 9KB
mobiscroll.core-2.5.2.css 9KB
mobiscroll.ios-2.5.1.css 8KB
green.css 8KB
black.css 8KB
blue.css 8KB
default.css 8KB
shCoreDefault.css 7KB
opera.css 7KB
aero.css 7KB
idialog.css 7KB
chrome.css 6KB
zTreeStyle.css 6KB
toolbar.css 6KB
twitter.css 6KB
simple.css 6KB
fullcalendar.print.css 5KB
fullcalendar.print.css 5KB
mobiscroll.android-ics-2.5.2.css 5KB
datepicker-dev.css 5KB
qunit.css 5KB
main.css 4KB
qunit.css 4KB
qunit.css 4KB
style.css 4KB
datepicker.css 4KB
scrawl.css 4KB
datepicker.css 4KB
datepicker.css 3KB
qq.css 3KB
pygments-manni.css 3KB
codemirror.css 3KB
image.css 3KB
tagit.css 3KB
charts.css 3KB
non-responsive.css 3KB
video.css 3KB
style.css 2KB
carousel.css 2KB
cover.css 2KB
background.css 2KB
blog.css 2KB
emotion.css 2KB
justified-nav.css 2KB
simple.css 2KB
demo.css 2KB
testsuite.css 2KB
mobiscroll.android-2.5.1.css 2KB
emotion.css 2KB
dialogbase.css 2KB
mobiscroll.sense-ui-2.5.1.css 2KB
music.css 2KB
mobiscroll.jqm-2.5.1.css 2KB
login.css 2KB
main.css 2KB
styles.css 2KB
dashboard.css 2KB
plain.css 1KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
毕业_设计
- 粉丝: 1932
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功