# 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.
## Basic Usage
Faker provides a factory method to create a `Faker\Generator` object. This object generates data by calling the type of data you want as a property.
```php
name;
// 'Lucy Cechtelar';
echo $faker->address;
// "426 Jordy Lodge
// Cartwrightshire, SC 88120-6700"
echo $faker->lorem;
// 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.
```
## Providers
As a matter of fact, a `Faker\Generator` alone can't do much generation. It needs `Faker\Provider` objects to delegate the data generation to them. `Faker\Factory` actually creates a `Faker\Generator` bundled with the default providers. Here is what happens under the hood:
```php
addProvider(new Faker\Provider\Name($faker));
$faker->addProvider(new Faker\Provider\Address($faker));
$faker->addProvider(new Faker\Provider\PhoneNumber($faker));
$faker->addProvider(new Faker\Provider\Company($faker));
$faker->addProvider(new Faker\Provider\Lorem($faker));
````
Whenever you try to access a property on the `$faker` object, the generator looks for a method with the same name in all the providers attached to it. For instance, calling `$faker->name` triggers a call to `Faker\Provider\Name::name()`.
That means that you can esily add your own providers to a `Faker\Generator`, or replace the ones bundled by defautl with a localized version. Just have a look at the existing providers to see how you can design powerful data generators in no time.
## Real Life Usage
The following script generates a valid XML document:
```php
country ?>
streetAddress ?>
city ?>
postcode ?>
state ?>
bs ?>
lorem(3) ?>]]>
```
Running this script produces a document looking like:
```xml
09678 Douglas Throughway
Cronaville
97573-1273
Wisconsin
enhance scalable vortals
413 Harber Street Apt. 536
Port Kaleighport
16436
Oregon
034 Pollich Fords Suite 763
Port Cloydberg
95235
NewHampshire
Pitcairn Islands
70028 Wisoky Wall
Tremblayberg
59624-3945
Ohio
unleash front-end deliverables
5208 Celia Route Suite 082
Port Albin
91670-9099
Wisconsin
692 Nelda Branch
North Shaina
40220
Nebraska
exploit sexy models
620 Watsica Extension
Quigleybury
31688-4724
Alaska
026 Florian Lights Apt. 130
North Mireille
68929
Maryland
cultivate rich infomediaries
485 Imani Falls Suite 202
Marvinbury
12186-1993
WestVirginia
streamline granular users
Italy
36949 Weissnat Cape
Swiftfort
80494
WestVirginia
```
## License
Faker is released under the MIT Licence.
Copyright (c) 2011 François Zaninotto
Portions Copyright (c) 2008 Caius Durling
Portions Copyright (c) 2008 Adam Royle
Portions Copyright (c) 2008 Fiona Burrows
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.