Faker
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Downloads
Component created
Component changed
Component body
Use the PHP Faker library to generate more meaningful sample content.
Devel Generate is great for creating a lot of sample content in a hurry, but sometimes you want samples that are more meaningful, or closer to the content you expect users to generate. This is where Faker comes in.
Faker is a PHP library that generates fake data for you
Faker (the library) can generate real looking names, addresses, emails, domains and more. Faker (the module) combines the library with quick content creation abilities provided by Devel Generate, to give you the power to easily generate real looking sample content.
Installation w/ Drush make
The module includes a drush make file that will automatically download the necessary library when installing via drush make. Just add faker to your project's drush make file.
Manual installation
- Download and unpack Faker from https://github.com/fzaninotto/Faker/archive/v1.1.0.tar.gz, into sites/all/libraries/faker.
- Download and enable the Faker module as usual.
Usage
- Implement
hook_faker_node_generate()from your module/feature. Seefaker.api.incin the source for more info about the available hooks. - Run devel generate either from drush or the admin UI.
Examples
function hook_faker_node_generate($node, $faker) {
if ($node->type == 'bio') {
$node->title = $faker->name;
$node->field_email['und'][0]['value'] = $faker->email;
$node->field_phone['und'][0]['value'] = $faker->phoneNumber;
}
}
