wimski/laravel-psr-http

PSR HTTP setup for Laravel
34,602 1
Install
composer require wimski/laravel-psr-http
Latest Version:v4.0.0
PHP:^8.3
License:MIT
Last Updated:Jul 10, 2026
Links: GitHub  ·  Packagist
Maintainer: wimski

Latest Stable Version Coverage Status PHPUnit PHPStan

Laravel PSR HTTP

This package provides Laravel bindings to make PSR HTTP requests using discovery.

Install

composer require wimski/laravel-psr-http

Usage example

<?php

declare(strict_types=1);

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;

class TestCommand extends Command
{
    protected $signature = 'http:test';
    protected $description = 'Test the HTTP client';

    public function __construct(
        protected ClientInterface $httpClient,
        protected RequestFactoryInterface $requestFactory,
        protected StreamFactoryInterface $streamFactory,
    ) {
        parent::__construct();
    }

    public function handle(): void
    {
        $stream = $this->streamFactory->createStream(json_encode([
            'title'  => 'foo',
            'body'   => 'bar',
            'userId' => 1,
        ]));

        $request = $this->requestFactory->createRequest('POST', 'https://jsonplaceholder.typicode.com/posts')
            ->withHeader('Content-type', 'application/json; charset=UTF-8')
            ->withBody($stream);

        try {
            $response = $this->httpClient->sendRequest($request);
            dump(json_decode((string) $response->getBody(), true));
        } catch (ClientExceptionInterface $exception) {
            dump($exception->getMessage());
        }
    }
}

Related Packages

garbetjie/http-request-logger

A request logger that can log all incoming & outgoing requests and responses.

1,858 5
larafony/core

Larafony is a modern PHP 8.5 framework combining the elegance of Laravel, the st...

65 89
php-http/laravel-httplug

Laravel package to integrate the Httplug generic HTTP client into Laravel

110,149 12
matthewbdaly/laravel-etag-middleware

A Laravel middleware for adding ETags to HTTP requests to improve response times

337,091 64
eleme/laravel-guzzle

laravel guzzle service provider

6,607 6

Version History

Version Released PHP Laravel License
v4.0.0 ^8.3 ^12.0 || ^13.0 MIT
v3.0.0 ^8.3 ^11.0 || ^12.0 MIT
v2.1.0 ^8.0 ^9.0 || ^10.0 || ^11.0 MIT
v2.0.0 ^8.0 ^9.0 || ^10.0 MIT
v1.1.0 ^7.4 || ^8.0 ^8.0 || ^9.0 MIT