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.
This module has no hard dependency on Devel Generate, but to benefit from all the features you will have to enable both.
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.
GitHub mirror: https://github.com/baikho/drupal-faker
Relevant modules
- Devel - See its submodule "Devel Generate"
Drupal 7
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.9.1.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.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[LANGUAGE_NONE][0]['value'] = $faker->email;
$node->field_phone[LANGUAGE_NONE][0]['value'] = $faker->phoneNumber;
}
}
Drupal 8
Installation
Just install as you would via composer and it will download the relevant Faker package.
Features
The 8.x
version adds "Faker Profile" config entities, that are out of the box available for use with the Devel Generate "Generate" tasks.
Project information
- Module categories: Content Editing Experience, Developer Tools, Integrations
- 10 sites report using this module
- Created by zroger on , updated
- Drupal 10 is here!
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Development version: 7.x-1.x-dev updated 8 May 2020 at 12:17 UTC