Framework

PHP Test Data Generation with MockHero

Client

<?php
use GuzzleHttp\Client;

$client = new Client();
$res = $client->post("https://api.mockhero.dev/api/v1/generate", [
  "headers" => [
    "x-api-key" => getenv("MOCKHERO_API_KEY"),
    "Content-Type" => "application/json",
  ],
  "json" => [
    "tables" => [
      ["name" => "users", "count" => 50, "fields" => [
        ["name" => "id", "type" => "uuid"],
        ["name" => "email", "type" => "email"],
      ]],
      ["name" => "orders", "count" => 200, "fields" => [
        ["name" => "id", "type" => "uuid"],
        ["name" => "user_id", "type" => "ref", "ref" => "users.id"],
        ["name" => "total", "type" => "price"],
      ]],
    ],
  ],
]);

$data = json_decode($res->getBody(), true);

Get Started

Free API key.

M

MockHero Team

Guides and tutorials for generating realistic test data with the MockHero API.

Start generating test data for free

1,000 rows/month on the free tier. No credit card required.

Get Your API Key

Related Articles