FrameworkUpdated

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.

D

Dino Sakoman

Founder of MockHero. Writes about synthetic test data, agent workflows, and database seeding with MockHero.

Start generating test data for free

500 records/day on the free tier. No credit card required.

Get Your API Key

Related Articles