2017 © Pedro Peláez
 

library json-faker

Create fake JSON with fzaninotto/Faker

image

mehr-als-nix/json-faker

Create fake JSON with fzaninotto/Faker

  • Sunday, February 12, 2017
  • by siad007
  • Repository
  • 2 Watchers
  • 0 Stars
  • 2,764 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 39 % Grown

The README.md

json-faker

Creates JSON fixtures with fzaninotto/Faker, (*1)

Build Status Total Downloads, (*2)

Installation

Add mehr-als-nix/json-faker dependency to the require section inside your composer.json, (*3)

"require": {
    "mehr-als-nix/json-faker": "*"
}

Examples

<?php

use MehrAlsNix\JsonFaker\JsonFaker;

$jsonTemplate = <<<JSON
{
  "options": [
    {
      "__JSON_OPTIONS__": "JSON_PRETTY_PRINT|JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP|JSON_UNESCAPED_SLASHES",
      "__NODE_CLONE__": 3
    }
  ],
  "fixture": [
    {
      "float-value": "__RAND_FLOAT__",
      "boolean-value": "__RAND_BOOLEAN__",
      "number-value": "__RAND_NUMBER__",
      "simple-text": "__RAND_TEXT__",
      "user-agent": "__RAND_USERAGENT__"
    }
  ]
}
JSON;

echo (string) new JsonFaker($jsonTemplate, false);

Running this script generates a JSON string with random values like:, (*4)

[
    {
        "float-value": 157176.955378,
        "boolean-value": true,
        "number-value": 855701,
        "simple-text": "pariatur ad",
        "user-agent": "Opera/8.99 (Windows NT 6.2; sl-SI) Presto/2.9.218 Version/12.00"
    },
    {
        "float-value": 1,
        "boolean-value": true,
        "number-value": 1207,
        "simple-text": "ex sit",
        "user-agent": "Mozilla/5.0 (iPad; CPU OS 7_1_1 like Mac OS X; sl-SI) AppleWebKit/535.11.1 (KHTML, like Gecko) Version/4.0.5 Mobile/8B118 Safari/6535.11.1"
    },
    {
        "float-value": 933,
        "boolean-value": true,
        "number-value": 59201435,
        "simple-text": "voluptatem qui",
        "user-agent": "Mozilla/5.0 (iPad; CPU OS 8_1_2 like Mac OS X; en-US) AppleWebKit/532.46.4 (KHTML, like Gecko) Version/4.0.5 Mobile/8B116 Safari/6532.46.4"
    }
]

The Versions

12/02 2017

dev-master

9999999-dev

Create fake JSON with fzaninotto/Faker

  Sources   Download

MIT

The Requires

 

The Development Requires

by Siad Ardroumli

json fixtures faker

12/02 2017

dev-develop

dev-develop

Create fake JSON with fzaninotto/Faker

  Sources   Download

MIT

The Requires

 

The Development Requires

by Siad Ardroumli

json fixtures faker

12/02 2017

v0.1.0

0.1.0.0

Create fake JSON with fzaninotto/Faker

  Sources   Download

MIT

The Requires

 

The Development Requires

by Siad Ardroumli

json fixtures faker