swisnl/laravel-psr-http-client-bridge

Laravel PSR-18 HTTP Client Bridge

dev-master / 1.0.x-dev 2022-05-17 09:11 UTC

This package is auto-updated.

Last update: 2023-03-17 11:03:49 UTC


README

Latest Version on Packagist Software License Buy us a tree Build Status Coverage Status Quality Score Total Downloads Made by SWIS

Provides a bridge to use the Laravel HTTP Client as PSR-18 (or PHP-HTTP) HTTP Client. Created as an experiment to use the HTTP response fakes and assertions in tests, for libraries that require a PSR-18 HTTP Client.

Install

Via Composer

$ composer require swisnl/laravel-psr-http-client-bridge

Usage

$client = new Swis\Laravel\Bridge\PsrHttpClient\Client();
$request = new Psr\Http\Message\RequestImplementation();
$response = $client->sendRequest($request);

If you want to configure some request options, you can provide a callable that returns a PendingRequest.

$client = new Swis\Laravel\Bridge\PsrHttpClient\Client(fn () => Http::withOptions(['proxy' => 'http://localhost:8125']));

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email security@swis.nl instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

SWIS ❤️ Open Source

SWIS is a web agency from Leiden, the Netherlands. We love working with open source software.