PHPackages                             tourze/http-forward-bundle - 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. tourze/http-forward-bundle

ActiveSymfony-bundle

tourze/http-forward-bundle
==========================

Symfony Bundle for HTTP request forwarding with middleware support

1.0.1(5mo ago)0901MITPHPCI failing

Since Nov 2Pushed 4mo agoCompare

[ Source](https://github.com/tourze/http-forward-bundle)[ Packagist](https://packagist.org/packages/tourze/http-forward-bundle)[ RSS](/packages/tourze-http-forward-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (49)Versions (3)Used By (1)

HTTP Forward Bundle
===================

[](#http-forward-bundle)

[English](README.md) | [中文](README.zh-CN.md)

**Symfony Bundle for HTTP request forwarding with middleware support**

An enterprise-grade HTTP request forwarding component with complete forwarding capabilities, middleware system, load balancing, and health checks.

Core Features
-------------

[](#core-features)

- ✅ **HTTP Request Forwarding** - Support all HTTP methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
- ✅ **Streaming Response** - Full support for SSE (Server-Sent Events) and chunked transfer
- ✅ **Middleware System** - 7 built-in middlewares for request/response transformation
- ✅ **Load Balancing** - Multiple backend support with automatic healthy node selection
- ✅ **Health Checks** - Proactive backend health monitoring
- ✅ **Retry Mechanism** - Automatic retry with exponential backoff
- ✅ **Fallback Handling** - Return preset responses when backends are unavailable
- ✅ **Access Control** - API key authentication to protect proxy endpoints
- ✅ **Visual Management** - EasyAdmin backend with drag-and-drop middleware configuration
- ✅ **Complete Logging** - Record request/response for troubleshooting

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

[](#installation)

```
composer require tourze/http-forward-bundle
```

Quick Start
-----------

[](#quick-start)

### 1. Basic Configuration

[](#1-basic-configuration)

Create forwarding rules via EasyAdmin:

1. Visit `/admin`
2. Navigate to **HTTP Forward** → **Forward Rules**
3. Create a new rule with:
    - **Path Pattern**: `/api/*`
    - **Backend URL**: `https://api.example.com`
    - **Middlewares**: Select required middlewares

### 2. Use Forward Controller

[](#2-use-forward-controller)

Accessing `/forward/api/users` will automatically forward to the configured backend.

### 3. Programmatic Usage

[](#3-programmatic-usage)

```
use Tourze\HttpForwardBundle\Service\ForwarderService;
use Tourze\HttpForwardBundle\Entity\ForwardRule;

class YourController
{
    public function __construct(
        private readonly ForwarderService $forwarderService,
    ) {}

    public function proxy(Request $request, ForwardRule $rule): Response
    {
        return $this->forwarderService->forward($request, $rule);
    }
}
```

Middleware System
-----------------

[](#middleware-system)

### Built-in Middlewares

[](#built-in-middlewares)

MiddlewareFunctionUse Case`access_key_auth`Access key authenticationProtect proxy endpoints, verify client identity`auth_header`Authorization header managementAdd/replace Authorization header`header_transform`Request header transformationAdd, remove, rename request headers`query_param`Query parameter handlingModify URL query parameters`xml_to_json`XML to JSON conversionResponse format transformation`retry`Retry mechanismAutomatically retry failed requests`fallback`Fallback handlingReturn default response when backend unavailable### Visual Configuration

[](#visual-configuration)

Configure middlewares via drag-and-drop in EasyAdmin:

1. Edit a forwarding rule
2. In the **Middlewares** field:
    - Select middleware from dropdown
    - Click "Add" button
    - Expand configuration form to fill parameters
    - Drag to adjust execution order

See: [Middleware Configuration Guide](MIDDLEWARE_CONFIG_GUIDE.md)

### Configuration Examples

[](#configuration-examples)

#### Access Key Authentication

[](#access-key-authentication)

```
{
  "type": "access_key_auth",
  "config": {
    "enabled": true,
    "required": true,
    "fallback_mode": "strict"
  }
}
```

#### Authorization Header Management

[](#authorization-header-management)

```
{
  "type": "auth_header",
  "config": {
    "action": "add",
    "scheme": "Bearer",
    "token": "your-api-key"
  }
}
```

#### Header Transformation

[](#header-transformation)

```
{
  "type": "header_transform",
  "config": {
    "add": {
      "X-Custom-Header": "value",
      "X-Client-Version": "1.0"
    },
    "remove": ["X-Internal-Header"],
    "rename": {
      "X-Old-Name": "X-New-Name"
    }
  }
}
```

#### Retry Mechanism

[](#retry-mechanism)

```
{
  "type": "retry",
  "config": {
    "max_attempts": 3,
    "delay_ms": 1000,
    "backoff_multiplier": 2.0,
    "retry_on_status": [429, 500, 502, 503, 504]
  }
}
```

Feature Details
---------------

[](#feature-details)

### Load Balancing

[](#load-balancing)

Support multiple backend configuration with automatic healthy node selection:

```
// Add multiple Backends to ForwardRule in EasyAdmin
// System will automatically round-robin among healthy backends
```

### Health Checks

[](#health-checks)

Use CLI command to check backend status:

```
# Check all backends
php bin/console http-forward:health-check

# Check specific backend
php bin/console http-forward:health-check --backend-id=1

# Set timeout (seconds)
php bin/console http-forward:health-check --timeout=10

# Dry run without modifying status
php bin/console http-forward:health-check --dry-run
```

### Streaming Response

[](#streaming-response)

Automatically detect and support SSE streaming:

```
// Enable stream_enabled in ForwardRule
// Or request with Accept: text/event-stream
```

### Request Logging

[](#request-logging)

All forwarding requests are logged in `ForwardLog` entity:

- Request/response headers
- Response status code
- Execution time
- Error messages
- Backend node

View in EasyAdmin: **HTTP Forward** → **Forward Logs**

Configuration Reference
-----------------------

[](#configuration-reference)

### Entity Relationships

[](#entity-relationships)

```
ForwardRule (Forwarding Rule)
├── name: Rule name
├── path_pattern: Path matching pattern (e.g., /api/*)
├── priority: Priority (higher number = higher priority)
├── stream_enabled: Enable streaming response
├── middlewares: Middleware configuration (JSON)
└── backends: Associated backend list

Backend (Backend Node)
├── name: Node name
├── url: Backend URL
├── weight: Weight (load balancing)
├── status: Health status
├── health_check_url: Health check URL
└── timeout: Timeout (seconds)

ForwardLog (Forward Log)
├── forward_rule: Applied rule
├── backend: Actual backend used
├── status: Request status
├── request_*: Request information
├── response_*: Response information
└── error_message: Error message

```

Use Cases
---------

[](#use-cases)

### API Gateway

[](#api-gateway)

```
Client → HTTP Forward Bundle → Multiple Backend Services
              ↓
        - Authentication middleware
        - Header transformation
        - Load balancing
        - Health checks
        - Request logging

```

### OpenAI Proxy

[](#openai-proxy)

Works with `open-ai-http-proxy-bundle` to provide complete OpenAI API proxy functionality.

### Microservice Routing

[](#microservice-routing)

Route requests to different microservices based on path rules, supporting:

- Dynamic routing rules
- Request/response transformation
- Service degradation
- Traffic control

Testing
-------

[](#testing)

```
# Run all tests
vendor/bin/phpunit

# Run specific tests
vendor/bin/phpunit tests/Service/ForwarderServiceTest.php

# Code quality check
vendor/bin/phpstan analyse
```

Documentation
-------------

[](#documentation)

- [PRD (Product Requirements Document)](PRD.md)
- [Feature Request Document](FEATURE_REQUEST.md)
- [Middleware Configuration Guide](MIDDLEWARE_CONFIG_GUIDE.md)

License
-------

[](#license)

MIT License - See [LICENSE](LICENSE) file

Related Projects
----------------

[](#related-projects)

Provides core forwarding capabilities as infrastructure component for `tourze/open-ai-http-proxy-bundle`.

---

**Version**: 1.0 **Maintainer**: Tourze Team

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance72

Regular maintenance activity

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Total

2

Last Release

175d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-http-forward-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-http-forward-bundle/health.svg)](https://phpackages.com/packages/tourze-http-forward-bundle)
```

###  Alternatives

[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
