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(1y ago)0212MITPHPPHP &gt;=8.1

Since Jun 8Pushed 1y 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 today

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 62% of packages

Maintenance48

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community10

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

Every ~2 days

Total

3

Last Release

387d 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

[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[bref/bref

Bref is a framework to write and deploy serverless PHP applications on AWS Lambda.

3.4k10.6M67](/packages/bref-bref)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[sunrise/http-router

A powerful solution as the foundation of your project.

17451.6k10](/packages/sunrise-http-router)[typo3/cms-adminpanel

TYPO3 CMS Admin Panel - The Admin Panel displays information about your site in the frontend and contains a range of metrics including debug and caching information.

115.7M66](/packages/typo3-cms-adminpanel)

PHPackages © 2026

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