Site icon WDB24

How to Integrate Faker as a Third Party into Codeigniter

codeigniter featured image

Faker is one of the most popular PHP library for generating fake data. I quite often use this library at the start of my project. Laravel has built-in faker library but for codeigniter I have to add faker as a third party library.

So in this post I am going to show you how to integrate faker into codeigniter.

Integrate Faker into Codeigniter:

Following are the steps involves in integration process:


Codeigniter Folder Structure:

After downloading default codeigniter structure is something like this.

Faker Folder Structure:

After downloading from github faker folder structure look like below.

Copy Faker Src folder to application/third_party:

Now copy faker src folder to codeigniter/application/third_party folder and rename src folder to faker.

Add Include path to the Controller (controllers/welcome.php):

Copy below Path to index function of welcome.php

Now initialize and use faker by assigning it to the variable.

Your final index function will look something like this

Also read:

Exit mobile version