Faker is a PHP library that generates dummy data. It is useful for developers who need to bootstrap MySQL database, create validated XML or JSON documents, and many more.
In this post we will take a look at how to integrate this library into CodeIgniter (CI) 3. You should have a working copy of CodeIgniter 3 before anything else.
Faker supports both PSR-0 as PSR-4 autoloaders so we can add it to CI using PSR-0 method.
- Add Faker library from https://github.com/fzaninotto/Faker
- Copy it to
application\third_party\faker
. - Include library in any controllers that requires it
include APPPATH . 'third_party/faker/autoload.php';

- Use Faker\Factory::create() to create and initialize faker
include APPPATH . 'third_party/faker/autoload.php'; $faker = Faker\Factory::create(); $data = array( 'fullname' => $faker->firstName.' '.$faker->lastName, 'age' => $faker->numberBetween(20, 60), 'tel' => $faker->phoneNumber, 'email' => $faker->email, ); $data2 = array( 'city' => $faker->city, 'color' => $faker->hexcolor(), 'description' => $faker->sentence($nbWords = 6, $variableNbWords = true) );