programmatordev/php-api-sdk

A fluent PHP library for creating API SDKs with PSR-18, PSR-17, PSR-6 and PSR-3 support

Maintainers

Package info

github.com/programmatordev/php-api-sdk

pkg:composer/programmatordev/php-api-sdk

Statistics

Installs: 10 209

Dependents: 2

Suggesters: 0

Stars: 1

Open Issues: 0

v3.0.0 2026-06-21 15:27 UTC

This package is auto-updated.

Last update: 2026-06-21 15:31:03 UTC


README

Latest Version Software License Tests

These docs describe how to create API SDKs with this package.

This package is built for two developer audiences:

  • SDK authors: developers creating concrete API SDKs with this library.
  • SDK users: developers consuming those SDKs in applications.

The goal is to keep SDK authoring fluent and compact, keep SDK usage focused on real API resources, and still expose enough control for developers who need to customize or work around an SDK.

The practical guides below show how to build resources, map responses, and configure the HTTP pipeline. Read Design Approach for more about the reasoning behind the API shape.

Requirements

  • PHP >=8.1
  • PSR-18 HTTP client support
  • PSR-17 request and stream factory support

The package uses PHP-HTTP discovery for PSR-18 clients and PSR-17 factories. When the php-http/discovery Composer plugin is enabled, missing implementations can be installed automatically from the supported virtual packages.

Installation

composer require programmatordev/php-api-sdk

SDK packages may still require or suggest concrete PSR-18 and PSR-17 implementations when they want tighter control over the default HTTP stack.

Guides

  • Getting Started: create a small SDK with an API facade, resource, entity, and response mapping.
  • Design Approach: the reasoning behind fluent SDK authoring, clean SDK usage, and hackability.
  • API: SDK facade setup methods, configuration, and extension points.
  • Resource Authoring: deeper guide for resource methods, query/header options, request bodies, entity mapping, collections, envelopes, and API-specific resource chains.
  • Resources: resource classes and endpoint request helpers.
  • Responses: decoded data, raw responses, entities, collections, envelopes, and context.
  • Authentication: configure bearer, basic, header, query, HTTPlug, and custom authentication.
  • HTTP Client: configure PSR-18 clients and PSR-17 factories.
  • Cache: configure PSR-6 HTTP response caching.
  • Logging: configure PSR-3 logging and HTTP/cache log output.
  • Plugins: configure HTTPlug middleware and priority ordering.
  • Hooks: run SDK-author callbacks around requests and responses.

Upgrading

See Upgrade to 3.0 for the high-level changes.