sdk-generator / sdk-runtime
Lightweight shared PHP runtime for contract-driven SDKs.
Requires
- php: ^8.4
- guzzlehttp/guzzle: ^7.9
- guzzlehttp/psr7: ^1.9.1 || ^2.0
- opis/json-schema: ^2.6.1
- psr/http-client: ^1.0
- psr/http-message: ^1.1 || ^2.0
- sdk-generator/typed-array: ^1.4.0
Requires (Dev)
- phpstan/phpstan: ^2
- phpunit/phpunit: ^11.5
Suggests
None
Provides
None
Conflicts
None
Replaces
- dmorenof/sdk-runtime: v1.16.0
- dev-main
- v1.16.0
- v1.15.0
- v1.14.2
- v1.14.1
- v1.14.0
- v1.13.0
- v1.12.1
- v1.12.0
- v1.11.1
- v1.11.0
- v1.10.1
- v1.10.0
- v1.9.0
- v1.8.0
- v1.7.0
- v1.6.1
- v1.6.0
- v1.5.0
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.0
- v0.31.0
- v0.30.0
- v0.29.0
- v0.28.0
- v0.27.0
- v0.26.1
- v0.26.0
- v0.25.0
- v0.24.0
- v0.23.0
- v0.22.1
- v0.22.0
- v0.21.0
- v0.20.0
- v0.19.0
- v0.18.0
- v0.17.1
- v0.17.0
- v0.16.0
- v0.15.0
- v0.14.0
- v0.13.0
- v0.12.0
- v0.11.1
- v0.11.0
- v0.10.1
- v0.10.0
- v0.9.0
- v0.8.0
- v0.7.0
- v0.6.0
- v0.5.0
- v0.4.0
- v0.3.1
- v0.3.0
- v0.2.0
- dev-claude/project-thread-irv7it
- dev-claude/project-thread-cpnvb3
- dev-claude/project-thread-4q82nk
- dev-claude/project-thread-f6vfxh
- dev-claude/project-thread-6rr5pz
This package is auto-updated.
Last update: 2026-12-04 02:07:29 UTC
README
The engine for typed PHP API clients, from an OpenAPI file or by hand. Transport, authentication (API key, basic, bearer, OAuth2 with automatic renewal, OpenID Connect with ID-token validation, mutual TLS), typed models validated where you assign, errors, retries, redirects, streaming and timeouts live here, written and tested once; an SDK holds only what is specific to its API. It is the base of every SDK made by sdk-generator, which reads OpenAPI 3.x, Swagger 2.0, RAML, Postman collections and browser HAR captures, and you can write your own client on it for an API that has no specification. PHP 8.4+.
Everything the generator and this runtime do, on one page: Everything it can do.
A client holds its own transport and credentials, and nothing is shared between clients.
Why use it
Measured on 2026-12-04 (runtime 1.16.0, generator 1.19.0) against OpenAPI Generator 7.26 on PHP 8.4, with the SDK each generator makes from the same published contract, a clean process per measurement and the same real answer served to both:
| This runtime + generator | OpenAPI Generator | |
|---|---|---|
| PokeAPI (102 operations): everything installed | 3.6 MB | 6.7 MB |
| PokeAPI: one Pokémon (350 KB of JSON), time per call | 0.50× (5.2 ms) | 10.5 ms |
| PokeAPI: peak memory of that call | 0.67× (9.7 MB) | 14.4 MB |
| met.no (Swagger, 12 operations): time per call | 0.33×–0.36× | |
| Casafari (46 operations): everything installed | 4.0 MB | 6.3 MB |
| PokeAPI + Wikimedia + met.no in one project: everything installed | 3.9 MB | 8.6 MB |
| Casafari: peak memory, nested models | 2.5 MB | 10 MB |
| Memory growth over thousands of calls | 4 KiB | 163–3,130 KiB |
And less to write: OAuth2 tokens are fetched and renewed for you, models are plain typed properties (no getters and setters), and retries, redirects, timeouts and proxies are one Configuration.
Where it is not better, said plainly: the runtime is paid once, so a single very small API installs more (met.no alone: 2.8 MB against 1.9 MB) and every further API on the same runtime only adds its own, smaller code (the three above together are half of OpenAPI Generator's), the first call in a fresh process is about 1.25× slower (with or without OPcache), and it needs PHP 8.4. The method and every table are in Why this runtime; every benchmark of the project, with its scripts and how to repeat it, is listed in the generator's Benchmarks.
In thirty seconds
use Acme\Accounts\{Configuration, Users}; use Acme\Accounts\DTOs\NewUser; Users::configure(new Configuration()); // an SDK generated from the API's specification $new = new NewUser(); $new->name = 'Ada'; $user = Users::post($new); // typed, validated model echo $user->id;
Documentation
| I want to… | Read |
|---|---|
| See what it costs and what it saves, measured | Why this runtime |
| Make my first call | Getting started |
| Work with models, parameters and errors | Using an SDK |
| Pass parameters, upload files, send cookies | Sending data |
| Authenticate (API key, bearer, basic, OAuth2) | Authentication |
| Set timeouts, retries, redirects, proxies, servers | Transport and servers |
| Read headers, files, streams and error bodies | Responses |
| Understand validation and formats | Validation |
| Write a client for an API with no specification | Writing an API client by hand |
| Write or change a generator | Operation metadata |
| Look up a class | API reference |
| Know what may change between versions | Public API and versioning |
The full index, with a one-minute model of how the pieces fit, is docs/README.md. Notes on features as they were introduced in versions 0.4 to 0.31 are kept in docs/archive.
Compatibility
From 1.0.0 the package follows Semantic Versioning. What is stable, what is internal and what counts as a breaking change is defined in docs/PUBLIC_API.md.
Development
Use PHP 8.4+ and Composer 2:
composer install bash ci/run-tests.sh
Source code belongs in src/ under Dmorenof\SdkRuntime\; tests belong in tests/.
GitHub Flow
Develop on a branch and open a PR. A version is published only when its work is finished and proven and the owner confirms (changing VERSION on main publishes); versions are not published piecemeal. See AGENTS.md, CONTRIBUTING.md and RELEASING.md.
License
MIT; see LICENSE.