Skip to content

SergePauli/yrestapi-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YrestAPI PHP SDK

Official PHP SDK for YrestAPI with PSR-18 HTTP client support.

Status

This repository contains the initial SDK skeleton. The public API may evolve before 1.0.0.

Requirements

Runtime

  • 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

Development

  • Composer
  • ext-dom required 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 composer

Installation

composer require yrestapi/yrestapi-php

Quick Start

<?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'],
]);

Design Goals

  • No dependency on a specific HTTP client
  • PSR-18 transport abstraction
  • PSR-7 request and response interoperability
  • Explicit methods for YrestAPI endpoints

Development

composer install

Testing

Run unit tests with:

composer test

Current 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 POST requests 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 model and preset behavior
  • 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.

License

MIT

About

Official PHP SDK for YrestAPI with PSR-18 support

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages