Faker Json is a library in PHP that uses the Faker library to generate valid JSONs from templates with variables.
The idea is to replace variables in the format ${variable}
or method(arguments)
with values generated by the Faker library.
composer require daavelar/faker-json
use Faker\Factory;
use FakerJson\FakerJson;
$fakerJson = new FakerJson($faker);
$template = '{
"name": "firstName",
"email": "email",
"phone": "phoneNumber",
"age": "numberBetween(18, 65)"
"company": {
"name": "companyName",
"address": "streetAddress",
"bs": "buildingNumber"
}
}';
$json = $fakerJson->generate($template);
echo $json;
This project is licensed under the MIT License - see the LICENSE file for details.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.