Download the PHP package silencenjoyer/api-sdk without Composer

On this page you can find all versions of the php package silencenjoyer/api-sdk. 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 api-sdk

🛠️ API SDK

A lightweight PHP framework for building typed HTTP API integrations.

Tests codecov Static Analyze Latest Stable Version PHP Version Require

Requirements

Installation

The package includes php-http/discovery and will auto-discover PSR-18/PSR-17 implementations. Install any compatible package alongside:

Overview

The SDK is organized around two layers:


Layer 1: Using an API client

Zero-config instantiation

If php-http/discovery is installed alongside compatible PSR-18/PSR-17 packages, the client discovers them automatically:

Explicit dependencies:

Advanced builder

For middleware or parser customization, obtain the builder first:

Authentication

Attach an auth strategy to a built instance. The call is immutable and returns a new instance:

Implement AuthInterface to create custom strategies (API key header, HMAC signature, etc.).

Executing commands

Two styles are available:

Working with the response


Layer 2: Building an API client

Minimal implementation

Providing default builder configuration

Override getBuilder() to apply defaults that are always needed for this API. The signature must match the parent:

AbstractApi::build() calls static::getBuilder(), so defaults are applied automatically for both NbuApi::build() and NbuApi::getBuilder().

Custom constructor parameters

If your API requires extra constructor arguments (e.g., an environment-specific base URL), add a named factory method that uses withFactory():

Implementing commands

Extend AbstractCommand and declare the HTTP semantics:

Override getBodyParams(), getHeaders(), getRequestContentType(), or getAnswerContentType() as needed.

For private commands, isPublic() must return false. The authentication strategy attached via withAuthentication() will sign the request automatically.

Per-command middleware

Attach middleware to a specific command class only:

Custom middleware

Implement MiddlewareInterface:

Custom parsers and serializers

Register additional format support on the builder:

Serializer resolution

When a command has body params, the SDK selects a serializer using this priority chain:

  1. getRequestContentType() — explicit override on the command.
  2. The Content-Type header already present on the request — set it via getHeaders() to let the SDK pick the serializer automatically.
  3. If neither provides a recognized content type, UnableToResolveSerializerException is thrown.

The recognized content types are controlled by withFormats() on the builder.

Parser resolution

After a response is received, the SDK selects a parser using this priority chain:

  1. getAnswerContentType() — explicit override on the command; bypasses all automatic detection.
  2. The Content-Type header on the response — matched against the content types registered via withFormats().
  3. Assumes — when the header is absent or unrecognized, the body is inspected by registered assume strategies. JsonAssume is active by default.
  4. If none of the above resolves, UnableToResolveParserException is thrown.

Content-type inference

When a response carries no Content-Type header, the SDK uses registered "assumes" to infer the format from the body. JSON is assumed by default. Register additional strategies:


Built-in components

Component Description
LoggerMiddleware Logs request and response bodies via PSR-3
RepeatableMiddleware Retries requests on 5xx by default; configurable condition and retry count
RateLimiterMiddleware Throttles outgoing requests via silencenjoyer/rate-limiter; blocks until the rate window allows
ThrowOnErrorStatusMiddleware Throws ClientHttpException on 4xx and ServerHttpException on 5xx; opt-in
Bearer Adds Authorization: Bearer <token> header
JsonParser Parses JSON responses
JsonSerializer Serializes request bodies as JSON
UrlEncodedSerializer Serializes request bodies as application/x-www-form-urlencoded

License

MIT


All versions of api-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4.0|^8.0.0
psr/http-message Version ^1.1|^2.0
psr/http-client Version ^1.0.0
psr/http-factory Version ^1.0.0
psr/log Version ~1.1.0
silencenjoyer/rate-limiter Version ^3.0.0
php-http/discovery Version ^1.0
ext-json Version *
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 silencenjoyer/api-sdk contains the following files

Loading the files please wait ...