Download the PHP package bentools/typed-http-client without Composer

On this page you can find all versions of the php package bentools/typed-http-client. 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 typed-http-client

Symfony Typed HTTP Client

CI Workflow Code Coverage License: MIT

A thin, type-safe decorator around Symfony's HTTP Client that hydrates responses into real objects instead of plain arrays.

You keep the whole HttpClientInterface API — including streaming — and get a getData() method on every response, returning whatever type your factory produces. Static analyzers (PHPStan, Psalm) follow the type all the way through, thanks to generics annotations.

Installation

Requires PHP >= 8.2. The library only depends on symfony/contracts; bring your own HttpClientInterface implementation (e.g. symfony/http-client, used by default when installed).

Usage

Quick start with a closure

The fastest way to get typed data out of a response is to pass a closure. It receives the raw response, the $throw flag, and a RequestContext:

Dedicated factory classes

For anything reusable, implement DataFactoryInterface. The @implements annotation is what makes generics click:

Discriminating by request

The RequestContext carries the method, url and options of the originating request, so a single factory can serve several endpoints:

Deriving clients

withFactory() returns a new client with a different factory, on the same transport. Handy for scoping one client per resource:

withOptions() works exactly like Symfony's, and keeps the factory:

Streaming

stream() works like Symfony's, and yields chunks keyed by the typed response:

Default behavior

Without a factory, the client falls back to ArrayDataFactory: getData() simply returns the JSON-decoded body as an array.

Error handling

getData(bool $throw = true) follows Symfony's convention: with $throw = true (the default), HTTP 4xx/5xx responses raise the usual ClientException / ServerException. Pass false to let your factory deal with erroneous payloads itself — the flag is forwarded to it.

Data is resolved lazily (nothing is decoded until you call getData()) and memoized (the factory runs at most once per response).

Design notes

Development

License

MIT.


All versions of typed-http-client with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
symfony/contracts Version ^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 bentools/typed-http-client contains the following files

Loading the files please wait ...