Middleware to forward requests and return responses

Package info

github.com/middlewares/proxy

pkg:composer/middlewares/proxy

Statistics

Installs: 4 106

Dependents: 1

Suggesters: 0

Stars: 22

Open Issues: 0

v2.1.0 2025-03-22 10:37 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT b193675fc43864efa2442172ad0bf77cb98143b7

httpservermiddlewarepsr-7psr-15

This package is auto-updated.

Last update: 2026-06-26 17:36:58 UTC


README

👁 Latest Version on Packagist
👁 Software License
👁 Testing
👁 Total Downloads

Middleware to create a http proxy using Guzzle.

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/proxy.

composer require middlewares/proxy

Example

$target = new Uri('http://api.example.com');

$dispatcher = new Dispatcher([
	new Middlewares\Proxy($target)
]);

$response = $dispatcher->dispatch(new ServerRequest());

Usage

You need a Psr\Http\Message\UriInterface with the target of the proxy.

use Middlewares\Utils\Dispatcher;
use Middlewares\Utils\Factory;

$target = Factory::createUri('http://api.example.com');

Dispatcher::run([
	new Middlewares\Proxy($target)
]);

client

Instance of the client used to execute the requests. If it's not provided, an instance of GuzzleHttp\Client is created automatically.

$target = Factory::createUri('http://api.example.com');
$client = new Client();

$proxy = (new Middlewares\Proxy($target))->client($client);

options

Options passed to the guzzle client. See the guzzle documentation for more information

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

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