Skip to content

daavelar/faker-json

Repository files navigation

Faker Json

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.

Installation

composer require daavelar/faker-json

Usage

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;

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

About

Transform your json in fake templates

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages