DummyJSON User Connector — Live Demo

About this demo

This sandbox exercises the kayrah87/dummyjson-user-connector package — a framework-agnostic PHP 8.4 connector for the DummyJSON users API.

Each demo page exercises one public method of UserService, lets you submit real input, and shows the response (or the exception that was thrown). Source-code snippets on each page show exactly what the consumer code looks like.

Public API covered

Get UsergetUser(int $id): User
Fetches a single user by ID. Demonstrates happy-path JSON decoding into the User DTO plus the UserNotFoundException path when the ID doesn't exist.
List UserslistUsers(int $limit = 30, int $skip = 0): UserPage
Paginated list. Returns a UserPage envelope that implements Countable and IteratorAggregate, so count($page) and foreach just work.
Create UsercreateUser(string $firstName, string $lastName, string $email): User
POSTs a new user. Input is trimmed and validated before the HTTP call — bad input throws ValidationException without wasting a round-trip. Returns the full User DTO including the generated id.

Exception hierarchy

Every error raised by the package implements the marker interface DummyJsonException, so one catch can trap anything from the package:

try {
    $user = $service->getUser(1);
} catch (DummyJsonException $e) {
    // $e is one of: UserNotFound, Validation, Transport, Api, InvalidResponse
}

How this demo was wired

The service is instantiated with one line:

$service = UserService::create();

That static factory uses php-http/discovery to find the PSR-18 client and PSR-17 factories already installed in the project — in this sandbox, that's Guzzle 7 via composer require. No other setup needed.