Download the PHP package daniel-jorg-schuppelius/php-api-toolkit without Composer

On this page you can find all versions of the php package daniel-jorg-schuppelius/php-api-toolkit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-api-toolkit

PHP API Toolkit

A reusable PHP library for building API client SDKs, targeting PHP 8.2+ with modern patterns and PSR compliance.

Features

Building blocks

The toolkit carries more than the client base class. Which of these an SDK needs depends on the API it wraps — the ones an SDK does not use are meant for the application embedding it, not dead weight:

Building block Use it for Used by the SDKs
Contracts\Abstracts\API\ClientAbstract client base: throttling, retry, log redaction all
Contracts\Abstracts\API\EndpointAbstract endpoint base: request helpers, response hydration all
Contracts\Abstracts\API\PagedEndpointAbstract searchAll() over page/size or limit/offset APIs lexoffice, orgamax
API\Pagination\OffsetPaginator page-number / offset pagination via PagedEndpointAbstract
API\Pagination\LinkHeaderPaginator, LinkHeader RFC 8288 Link header pagination datev
API\Pagination\CursorPaginator cursor/continuation-token pagination — (no API needs it yet)
API\Authentication\* Bearer, Basic, API key, HMAC, OAuth2 grants Bearer/Basic (all), OAuth2 (datev)
Contracts\Interfaces\API\RefreshableAuthenticationInterface self-healing credentials after a 401 orgamax
API\Webhook\WebhookVerifier verifying inbound webhook signatures — application-side, see below
API\Cache\Psr16ResponseCache conditional requests / response caching — application-side
API\PendingRequest fluent one-off requests outside an endpoint — application-side
API\Transport\Psr18Transport routing through a PSR-18 client instead of Guzzle — application-side
Testing\MockApiClient endpoint tests without HTTP lexoffice, orgamax

Application-side means: an SDK exposes the API surface, but signature verification, caching and transport choice belong to the application that receives the webhooks, owns the cache and picks the HTTP stack. Wiring them into an SDK would decide those questions for every consumer.

IDs in entities

NamedEntity::toArray()/toJson() emit a property typed as ID, GUID or UUID as its bare value, whatever entity name the ID class carries: {"employee_id": "…"}, not {"employee_id": {"guid": "…"}}. Where an API really wraps an ID in an object, the ID subclass opts in:

Other NamedValue types keep their object form ({"customer": {"number": 10308}}).

Installation

Quick Start

Advanced: Custom HttpClient

For advanced use cases (custom middleware, handler stacks, etc.), you can still provide your own HttpClient:

Authentication

The toolkit provides three authentication strategies out of the box:

Bearer Token (OAuth2, JWT)

Basic Authentication

API Key

OAuth2 Client Credentials (Machine-to-Machine)

For APIs without user interaction (e.g. UPS, FedEx, Microsoft Graph app-only). Tokens are fetched, cached and re-fetched on expiry automatically; after a 401 the token is discarded and the request retried exactly once.

Certificate-based clients (private_key_jwt, RFC 7523 — e.g. Microsoft Entra ID certificate credentials) sign a JWT client assertion instead of sending a secret (requires the openssl extension):

OAuth2 Resource Owner Password (B2B web services)

For providers that authenticate the user with name and password at the token endpoint (RFC 6749 section 4.3, e.g. Open Masterdata of the German SHK wholesale). The client secret is optional — many of these providers register public clients. Tokens are stored through OAuth2TokenStoreInterface, renewed via the refresh token and, if that fails, by a fresh login; after a 401 the client logs in again and retries once.

Custom Authentication

Implement AuthenticationInterface for custom auth strategies:

Endpoint-style Base URLs

Configuration fields often carry a full endpoint as "base URL". buildUrl() merges such a base with a sibling path without duplicating segments:

Rate Limiting

Retry Logic

The server's wait hint wins over the backoff: Retry-After is honored in all its spellings — delta-seconds, HTTP-date, fractional seconds and Go durations (6m0s, as sent by OpenAI). When Retry-After is missing, the rate-limit reset headers (x-ratelimit-reset-requests, anthropic-ratelimit-…-reset) serve as the fallback hint.

Quota errors are not retried. A 429 whose body carries a quota code (insufficient_quota, billing_hard_limit_reached, …) means the budget is spent, not the rate window — retrying is futile, so the exception is thrown immediately. Override shouldRetry() to change the policy.

Retries are method-aware (BEHAVIOR CHANGE in > v2.9.1). Only idempotent methods (RFC 7231/4918: GET, HEAD, OPTIONS, TRACE, PUT, DELETE, plus the WebDAV verbs PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, UNLOCK, REPORT, SEARCH, ORDERPATCH, ACL) are retried after a request went out. Non-idempotent methods (POST, PATCH, LOCK, unknown verbs) are no longer retried blindly on 429/5xx/transport errors — the server may already have executed the action, and a retry would perform it twice (observed in the wild as duplicated Toggl time entries). A POST is still retried when

Log levels follow the outcome. An attempt that is retried is logged as a single WARNING (Retrying GET /… (attempt n of m)); only the final failure is logged — once — as ERROR, also for an exhausted 429. Non-retryable responses keep their level (4xx WARNING, 5xx ERROR). ApiExceptions created inside ApiException::deferLogging() stay silent until $e->log() is called; the client uses this around handleErrorResponse(), so overrides of that method get the same behavior.

Arbitrary HTTP methods (WebDAV/CalDAV)

request() sends any HTTP method through the full client pipeline (throttling, auth, middleware, method-aware retry, error mapping) — no need to fall back to raw Guzzle for WebDAV/CalDAV verbs:

Timeouts

Default Headers

Default Query Parameters

User-Agent

Proxy Support

SSL Verification

⚠️ Warning: Disabling SSL verification is insecure. For self-signed certificates prefer setCaBundle(), which keeps verification enabled.

Complete Configuration Example

Exception Handling

HTTP errors are automatically converted to typed exceptions:

Every ApiException exposes the parsed error envelope: getErrorCode() / getErrorCodes() (flat and nested {"error": {"code", "type"}} forms), getErrorMessage() and getProblemDetails() (RFC 7807). The static ApiException::errorCodesOf($response) reads the codes from a PSR-7 response without consuming its body.

Status Code Exception
400 BadRequestException
401 UnauthorizedException
402 PaymentRequiredException
403 ForbiddenException
404 NotFoundException
405 NotAllowedException
406 NotAcceptableException
408 RequestTimeoutException
409 ConflictException
415 UnsupportedMediaTypeException
422 UnprocessableEntityException
429 TooManyRequestsException
500 InternalServerErrorException
502 BadGatewayException
503 ServiceUnavailableException
504 GatewayTimeoutException

Testing

Testing\MockApiClient implements ApiClientInterface and answers registered method/URI patterns, so endpoint logic can be tested without HTTP:

It covers endpoint behaviour, not the transport. URL building, headers, auth and retry only get exercised by a test against the real client with an injected Guzzle MockHandler — that is the layer where a swallowed base path or a wrong Content-Type hides.

License

MIT License - see LICENSE for details.


All versions of php-api-toolkit with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1 <8.6
guzzlehttp/guzzle Version ^7.10 || ^8.0
dschuppelius/php-common-toolkit Version ^1.19 || ^2.0
dschuppelius/php-error-toolkit Version ^2.4
ramsey/uuid Version ^4.9
psr/simple-cache Version ^1.0 || ^2.0 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package daniel-jorg-schuppelius/php-api-toolkit contains the following files

Loading the files please wait ...