A slim psr compliant http client to provide better interoperability.

Fund package maintenance!

2.0.0 2021-07-13 08:09 UTC

This package is auto-updated.

Last update: 2021-07-13 08:10:25 UTC


Latest Version Software License PHP Version run-tests Total Downloads

The purpose of this package is to create an interoperable http client implementation allowing a "bring you own packages" approach to connection to 3rd party services.

The main goal of this package is to adhere to the following PSRs:


Using composer:

$ composer require juststeveking/http-slim

You are then free to use it as needed within your projects.

Next steps

The next step is to install a compliant package to do the request itself.

A few packages that are recommended:


Once you have a client to inject, you can set up an easy to use and consistent implementation. The following example is using the Symfony HttpClient as it has the best documentation I have seen so far.



use JustSteveKing\HttpSlim\HttpClient;
use Symfony\Component\HttpClient\Psr18Client;

$httpClient = HttpClient::build(
    new Psr18Client(), // our client
    new Psr18Client(), // our request factory
    new Psr18Client() // our stream factory

// perform a get request

// perform a post request
    ['foo' => 'bar']

// perform a put request
    ['foo' => 'bar']

// perform a patch request
    ['foo' => 'bar']

// perform a delete request

// perform an options request
    ['X-OPTIONAL' => 'headers']


There is a composer script available to run the tests:

$ composer run preflight:test

However, if you are unable to run this please use the following command:

$ ./vendor/bin/phpunit --testdox


If you discover any security related issues, please email juststevemcd@gmail.com instead of using the issue tracker.