In this article, we are going to implement a PHP library to generate fake user details. Various detail parameters like name, address, phone number, emails and others can be generated using this PHP library.
Step 1 :
Download PHP Library Faker from here : https://github.com/fzaninotto/Faker
Step 2 :
Include the libary and create an instance of it like this
require_once 'Faker/src/autoload.php'; $faker = Faker\Factory::create();
The complete source code is provided below :
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> <style> ul{ list-style-type: none; padding-left:15px; margin-top:25px; } li{ margin-top:10px; } h3{ font-size:1.65rem; } .card-wrapper{ margin-bottom: 10px; } .card-body{ padding-right: 14px; padding-top:0px; padding-left:15px; height:250px; border:1px ridge #999999; } .left-col{ border-right:1px solid #ffffff; display:flex; align-items:center; height:248px; background:#ace2ce; } .user-image{ border-radius:50%; width:100%; } .right-col{ background: #95acff; } hr{ border:1px solid #dddddd; } </style> <?php require_once 'Faker/src/autoload.php'; $faker = Faker\Factory::create(); ?> <div class="container"> <h1 class="text-center mt-3">Fake User Details Generator</h1> <hr> <div class="row"> <?php for($i=0;$i<6;$i++){?> <div class="col-6 card-wrapper"> <div class="card-body"> <div class="row"> <div class="col-4 left-col"> <img class="user-image" src="https://thispersondoesnotexist.com/image"> </div> <div class="col-8 right-col"> <h3 class="text-center mt-4"><?php echo $faker->name;?></h3> <hr> <ul> <li>Phone : <?php echo $faker->phoneNumber;?></li> <li>Email : <?php echo $faker->email;?></li> <li>Address : <?php echo $faker->address;?></li> </ul> </div> </div> </div> </div> <?php } ?> </div> </div>
Follow this video for complete guidance :