Official PHP SDK for YrestAPI with PSR-18 HTTP client support.
This repository contains the initial SDK skeleton. The public API may evolve before 1.0.0.
- PHP 8.1+
ext-json- A PSR-18 HTTP client implementation
- PSR-17 factories for requests and streams
The SDK does not ship with a concrete HTTP client. Your application must provide:
- a PSR-18 client implementing
Psr\Http\Client\ClientInterface - a PSR-17 request factory
- a PSR-17 stream factory
Example application dependencies:
composer require symfony/http-client nyholm/psr7- Composer
ext-domrequired by PHPUnit
Example setup for Ubuntu or Debian:
sudo apt update
sudo apt install php8.3-cli php8.3-curl php8.3-mbstring php8.3-xml php8.3-zip unzip composercomposer require yrestapi/yrestapi-php<?php
declare(strict_types=1);
use Nyholm\Psr7\Factory\Psr17Factory;
use Symfony\Component\HttpClient\Psr18Client;
use YrestApi\YrestApiClient;
$httpClient = new Psr18Client();
$psr17Factory = new Psr17Factory();
$client = new YrestApiClient(
baseUrl: 'http://localhost:8080',
httpClient: $httpClient,
requestFactory: $psr17Factory,
streamFactory: $psr17Factory
);
$result = $client->index([
'model' => 'Project',
'preset' => 'with_members',
'limit' => 2,
'sorts' => ['id ASC'],
]);- No dependency on a specific HTTP client
- PSR-18 transport abstraction
- PSR-7 request and response interoperability
- Explicit methods for YrestAPI endpoints
composer installRun unit tests with:
composer testCurrent test coverage is unit-level only. The test suite does not require a running YrestAPI service because it uses a fake PSR-18 client and verifies that the SDK:
- sends
POSTrequests to/api/index - sets JSON request headers
- decodes JSON responses into PHP arrays
- works against PSR-18 interfaces rather than a specific HTTP client
This means the current tests do not validate:
- connectivity to a live YrestAPI instance
- real
modelandpresetbehavior - authentication against a running service
- compatibility with your deployment environment
Integration tests can be added later as a separate suite that runs against a live YrestAPI instance, for example on http://localhost:8080.
MIT