PHPackages                             monk24215/url-redirect-php-request-forwarder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. monk24215/url-redirect-php-request-forwarder

ActiveLibrary[HTTP &amp; Networking](/categories/http)

monk24215/url-redirect-php-request-forwarder
============================================

Framework-agnostic PHP HTTP request forwarder with retry, full passthrough, and pluggable logging.

v1.0.0(2mo ago)01MITPHPPHP &gt;=8.0CI failing

Since May 16Pushed 2mo agoCompare

[ Source](https://github.com/monk24215/url-redirect-php-request-forwarder)[ Packagist](https://packagist.org/packages/monk24215/url-redirect-php-request-forwarder)[ RSS](/packages/monk24215-url-redirect-php-request-forwarder/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

url-redirect-php-request-forwarder
==================================

[](#url-redirect-php-request-forwarder)

A small, framework-agnostic PHP library for forwarding HTTP requests with faithful passthrough, automatic retry, and pluggable logging.

[![Tests](https://github.com/monk24215/url-redirect-php-request-forwarder/actions/workflows/tests.yml/badge.svg)](https://github.com/monk24215/url-redirect-php-request-forwarder/actions/workflows/tests.yml)[![Packagist Version](https://camo.githubusercontent.com/acea090d9675806742de190df8bd358fcfde64e2fcfc1faad6ae71cd3306cbc4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f6e6b32343231352f75726c2d72656469726563742d7068702d726571756573742d666f727761726465722e737667)](https://packagist.org/packages/monk24215/url-redirect-php-request-forwarder)[![PHP Version](https://camo.githubusercontent.com/c43a736f738fa982a023ed7fc827895810d2ca0f353aa53674e0691bccea1034/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e302d626c7565)](https://php.net)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)

What it does
------------

[](#what-it-does)

- Forwards method, query string, body, headers, and cookies verbatim to any target URL
- Retries on transient failures (5xx, network errors) with exponential backoff
- Does **not** retry 4xx — those are client-side conditions that won't change
- Strips hop-by-hop headers (`Host`, `Content-Length`, `Connection`, etc.) automatically
- Returns a structured `ForwardResult` object (status, body, headers, attempts, duration, error)
- Optional transparent proxy mode (echoes upstream response back to the caller)
- Pluggable logging — ships with file (JSONL), PDO (MySQL/Postgres/SQLite), null, or bring your own

What it does NOT do
-------------------

[](#what-it-does-not-do)

- **It cannot guarantee 100% delivery.** Networks fail, targets go down, certificates expire. What this library guarantees is faithful passthrough, sensible retry behavior, and structured error reporting so your caller can make informed decisions.
- It is not a streaming proxy — request and response bodies are buffered in memory. For multi-gigabyte payloads use a different tool.
- It does not handle authentication for you — pass any auth headers in via the `headers` option.

Installation
------------

[](#installation)

```
composer require monk24215/url-redirect-php-request-forwarder
```

Requires PHP 8.0+, ext-curl, ext-json.

Quick start
-----------

[](#quick-start)

### Basic forward

[](#basic-forward)

```
use RequestForwarder\RequestForwarder;

$rf = new RequestForwarder('https://api.example.com/webhook', [
    'method'  => 'POST',
    'headers' => ['Content-Type' => 'application/json'],
    'body'    => json_encode(['event' => 'order.created']),
]);

$resp = $rf->forward();

if ($resp->ok) {
    echo "Forwarded successfully in {$resp->durationMs}ms";
} else {
    error_log("Forward failed after {$resp->attempts} attempts: {$resp->error}");
}
```

### Transparent proxy (relay incoming request to upstream)

[](#transparent-proxy-relay-incoming-request-to-upstream)

Drop this as `index.php` in any document root and every request to that domain will be proxied to the target, with the URL bar unchanged:

```
