Faker

Component ID

1944878

Component name

Faker

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Downloads

787

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

Usage

  • Implement hook_faker_node_generate() from your module/feature. See faker.api.inc in 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;
  }
}