daavelar/faker-json

There is no license information available for the latest version (2.0.6) of this package.

2.0.6 2024-06-10 17:35 UTC

This package is auto-updated.

Last update: 2024-11-15 17:50:53 UTC


README

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.