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

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

beauty-framework/http
=====================

Beauty HTTP module

1.0.2(11mo ago)0212MITPHPPHP &gt;=8.1

Since Jun 8Pushed 11mo agoCompare

[ Source](https://github.com/beauty-framework/http)[ Packagist](https://packagist.org/packages/beauty-framework/http)[ RSS](/packages/beauty-framework-http/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (4)Used By (2)

Beauty HTTP Component
=====================

[](#beauty-http-component)

The `beauty-framework/http` package is a lightweight, PSR-compatible HTTP layer for building clean, modular, and fast REST APIs. It is designed to be used as part of the `beauty-framework/app`, but can also be used independently in any modern PHP project.

---

Features
--------

[](#features)

- PSR-7 compatible `HttpRequest` and custom `JsonResponse`
- PSR-15 compatible middleware system via `AbstractMiddleware`
- Route-level middleware via PHP 8 attributes
- Support for:

    - `JsonResponse`
    - `StreamedResponse`
    - `BinaryFileResponse`
    - `RedirectResponse`
- `ResponsibleInterface` for clean resource-to-response conversion
- Resource system similar to Laravel's `JsonResource`
- Type-safe request abstraction for validated input (`HttpRequest` extensions)
- Extendable response normalization via `ResponseFactory`

---

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

[](#installation)

```
composer require beauty-framework/http
```

---

Usage Example
-------------

[](#usage-example)

### Validated Request

[](#validated-request)

```
namespace App\Requests;

use Beauty\Http\Request\AbstractValidatedRequest;

class CreateUserRequest extends AbstractValidatedRequest
{

    public function rules(): array
    {
        return [
            'name' => ['required'],
            'email' => ['required', 'email'],
            'password' => ['required', 'min:6'],
        ];
    }
}
```

```
use Beauty\Http\Enums\HttpMethodsEnum;
use App\Requests\CreateUserRequest;

class UserController
{
    #[Route(HttpMethodsEnum::POST, '/create')]
    public function create(CreateUserRequest $request): ResponsibleInterface
    {
        // ...
    }
}
```

### JsonResponse

[](#jsonresponse)

```
use Beauty\Http\Response\JsonResponse;

return new JsonResponse(200, ['message' => 'Hello world']);
```

### Redirect

[](#redirect)

```
use Beauty\Http\Response\RedirectResponse;

return new RedirectResponse('/login');
```

### File Download

[](#file-download)

```
use Beauty\Http\Response\BinaryFileResponse;

return new BinaryFileResponse('/path/to/report.pdf');
```

### Streamed Response

[](#streamed-response)

```
use Beauty\Http\Response\StreamedResponse;

return new StreamedResponse(function () {
    echo json_encode(['streamed' => true]);
});
```

### Custom Resource

[](#custom-resource)

```
use Beauty\Http\Response\AbstractJsonResource;

class UserResource extends AbstractJsonResource
{
    protected array $fields = ['id', 'name', 'email'];

    public function __construct(private object $user)
    {
        foreach ($this->fields as $field) {
            $this->{$field} = $user->{$field};
        }
    }
}

return (new UserResource($user))->setStatusCode(201);
```

---

Middleware (PSR-15 via AbstractMiddleware)
------------------------------------------

[](#middleware-psr-15-via-abstractmiddleware)

```
use Beauty\Http\Middleware\AbstractMiddleware;
use Beauty\Http\HttpRequest;
use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ResponseInterface;

class ExampleMiddleware extends AbstractMiddleware
{
    public function handle(HttpRequest $request, RequestHandlerInterface $handler): ResponseInterface
    {
        if ($request->query('blocked')) {
            return new JsonResponse(403, ['error' => 'Access denied']);
        }

        return $handler->handle($request);
    }
}
```

---

Attribute-Based Middleware
--------------------------

[](#attribute-based-middleware)

```
use Beauty\Http\Attributes\Middleware;
use Beauty\Http\Response\Contracts\ResponsibleInterface;

#[Middleware(AuthMiddleware::class)]
class UserController
{
    #[Route(HttpMethodsEnum::GET, '/me')]
    #[Middleware(ThrottleMiddleware::class)]
    public function me(): ResponsibleInterface
    {
        // ...
    }
}
```

---

Testing
-------

[](#testing)

```
./vendor/bin/phpunit
```

Tests are included for all response types and middleware pipeline behavior.

---

License
-------

[](#license)

MIT License.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance51

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

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

Every ~2 days

Total

3

Last Release

341d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/068f8c26f06f513a9c38d2a01c4d90a85eae1125a5b9d14eae7059715be860e4?d=identicon)[m1n64](/maintainers/m1n64)

---

Top Contributors

[![m1n64](https://avatars.githubusercontent.com/u/24874264?v=4)](https://github.com/m1n64 "m1n64 (3 commits)")

---

Tags

httpbeauty

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mezzio/mezzio-authentication-oauth2

OAuth2 (server) authentication middleware for Mezzio and PSR-7 applications.

28483.0k2](/packages/mezzio-mezzio-authentication-oauth2)[openswoole/core

Openswoole core library

181.1M32](/packages/openswoole-core)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

121.6M26](/packages/mezzio-mezzio-authentication)[sunrise/http-router

A powerful solution as the foundation of your project.

16249.8k10](/packages/sunrise-http-router)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[wellrested/wellrested

Simple PHP Library for RESTful APIs

4818.7k4](/packages/wellrested-wellrested)

PHPackages © 2026

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