PHPackages                             switon/http - 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. switon/http

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

switon/http
===========

Controller-based HTTP boundary with request input, response shaping, lifecycle hooks, and runtime adapters for Switon Framework

v1.0.0(1mo ago)02210MITPHPPHP &gt;=8.3CI passing

Since Jun 6Pushed 2mo agoCompare

[ Source](https://github.com/switon-php/http)[ Packagist](https://packagist.org/packages/switon/http)[ Docs](https://github.com/switon-php/http)[ RSS](/packages/switon-http/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (18)Versions (2)Used By (10)

Switon HTTP Package
===================

[](#switon-http-package)

[![HTTP CI](https://camo.githubusercontent.com/79dc1b25364b4fb7f7e405c4539c441856f14f9274636ada7a72b5661cf5205c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737769746f6e2d7068702f687474702f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d485454502532304349)](https://github.com/switon-php/http/actions/workflows/ci.yml) [![PHP 8.3+](https://camo.githubusercontent.com/c03f51341eebaefabbf137e291b20523fc74b4ffd084406d88524d266d95085d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d373737424234)](https://www.php.net/)

Switon's HTTP pipeline for request and response handling, attribute routing, action return normalization, request-stage filters, and transport adapters.

Highlights
----------

[](#highlights)

- **Request pipeline:** `RequestHandlerInterface` drives adjust, auth, route, validate, invoke, render, and finish stages.
- **Attribute routes:** `#[RequestMapping]` and action mappings keep routes close to controllers.
- **Action input binding:** `RequestBody`, `RequestData`, `RequestQuery`, and `Filters` shape action input.
- **Request filters:** cross-cutting filters can add request IDs, locale, CORS, and slowlog handling.
- **Return normalization:** `NormalizeActionReturnTransformer` turns common return values into framework responses.
- **Response helpers:** `ResponseInterface` covers `json()`, `text()`, `raw()`, and `redirect()`.
- **Runtime modes:** `ServerOptions` can switch between `auto`, `fpm`, `php`, and `swoole`.

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

[](#installation)

```
composer require switon/http
```

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

[](#quick-start)

```
use Switon\Core\Attribute\Autowired;
use Switon\Http\Controller;
use Switon\Http\RequestInterface;
use Switon\Http\ResponseInterface;
use Switon\Routing\Attribute\GetMapping;
use Switon\Routing\Attribute\RequestMapping;

#[RequestMapping('/api/users')]
final class UserController extends Controller
{
    #[Autowired] protected RequestInterface $request;
    #[Autowired] protected ResponseInterface $response;

    #[GetMapping('{id}')]
    public function showAction(int $id): array
    {
        return [
            'id' => $id,
            'locale' => $this->request->query('locale'),
        ];
    }

    #[GetMapping('{id}/raw')]
    public function rawAction(int $id): ResponseInterface
    {
        return $this->response->json(['id' => $id]);
    }
}
```

Docs:

License
-------

[](#license)

MIT.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance87

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

48d ago

### Community

Maintainers

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

---

Top Contributors

[![switon-php](https://avatars.githubusercontent.com/u/247358032?v=4)](https://github.com/switon-php "switon-php (15 commits)")

---

Tags

httprequestsresponsesserverswitonhttpserverrequestsresponsesswiton

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/switon-http/health.svg)

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

###  Alternatives

[nategood/httpful

A Readable, Chainable, REST friendly, PHP HTTP Client

1.8k17.7M275](/packages/nategood-httpful)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78027.7M474](/packages/react-http)[amphp/http-server

A non-blocking HTTP application server for PHP based on Amp.

1.3k6.7M115](/packages/amphp-http-server)[swow/swow

Coroutine-based multi-platform support engine with a focus on concurrent I/O

1.3k2.2M89](/packages/swow-swow)[psr/http-server-handler

Common interface for HTTP server-side request handler

180114.7M1.3k](/packages/psr-http-server-handler)[sunrise/http-router

A powerful solution as the foundation of your project.

17451.8k11](/packages/sunrise-http-router)

PHPackages © 2026

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