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

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

codebr/http-flow
================

Uma lib leve para manipulação de Request e Response com suporte total a verbos HTTP./A lightweight library for handling Requests and Responses with full support for HTTP verbs.

v0.1.1(4mo ago)031MITPHPPHP &gt;=8.1

Since Dec 20Pushed 4mo agoCompare

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

READMEChangelogDependencies (1)Versions (3)Used By (1)

HttpFlow 🌊
==========

[](#httpflow-)

[![Latest Version on Packagist](https://camo.githubusercontent.com/85fcf6079f71cb3edc9160daec63fcf25eb87a63a6b67a4785dbf804807c4723/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f646562722f687474702d666c6f772e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codebr/http-flow)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Uma biblioteca PHP leve, moderna e robusta para manipulação de requisições HTTP. Projetada para ser simples, testável e independente de frameworks pesados.

🚀 Funcionalidades
-----------------

[](#-funcionalidades)

- **Normalização de Headers**: Transforma automaticamente `HTTP_USER_AGENT` em `User-Agent`.
- **Suporte a JSON**: Deteta e decodifica automaticamente corpos de requisição em JSON.
- **Globais Customizadas**: Disponibiliza variáveis como `$_PUT`, `$_PATCH` e `$_DELETE`.
- **Filtros Inteligentes**: Métodos `only()`, `except()` e `input()` para manipulação limpa de dados.
- **Testabilidade**: Arquitetura pronta para testes unitários com injeção de dependências.
- **Request Handling**: Suporte total a JSON, Query Params e Body.
- **Fluent Response**: Interface fluida para retornos JSON, HTML e estados de erro.
- **CORS Automático**: Gestão de Preflight (OPTIONS) com configuração via ENV.
- **Arquivos de Upload**: Suporte a arquivos de upload via `multipart/form-data`.
- **Arquitetura Limpa**: Configurações desacopladas e prontas para testes unitários.
- **Suporte a Uploads**: Interface simplificada para gestão de ficheiros (`$_FILES`).

HTTP\_FLOW\_ALLOW\_ORIGIN=HTTP\_FLOW\_ALLOW\_METHODS=GET,POST,PUT,DELETE,OPTIONS HTTP\_FLOW\_ALLOW\_HEADERS=Content-Type,Authorization,X-Requested-With HTTP\_FLOW\_MAX\_AGE=3600 HTTP\_FLOW\_ALLOW\_CREDENTIALS=true

📦 Instalação
------------

[](#-instalação)

Pode instalar a biblioteca via Composer:

```
composer require codebr/http-flow

use Codebr\HttpFlow\Request;

$request = new Request();

// Obter o método e a URI
echo $request->getMethod(); // GET, POST, PUT...
echo $request->getUri();    // /users/profile

// Busca 'id' em qualquer lugar da requisição, com valor padrão null
$id = $request->input('id');

// Busca com valor padrão se não existir
$page = $request->input('page', 1);

// Retorna apenas os campos desejados
$userData = $request->only(['name', 'email', 'password']);

// Retorna tudo, exceto campos sensíveis
$updateData = $request->except(['is_admin', 'id']);

$headers = $request->getHeaders();
$userAgent = $headers['User-Agent'] ?? 'Unknown';

# Origem permitida (padrão: *)
HTTP_FLOW_ALLOW_ORIGIN=[https://meuapp.com](https://meuapp.com)

# Métodos permitidos (padrão: GET,POST,PUT,DELETE,OPTIONS)
HTTP_FLOW_ALLOW_METHODS=GET,POST,PUT,DELETE

# Headers permitidos
HTTP_FLOW_ALLOW_HEADERS=Content-Type,Authorization,X-Requested-With

# Tempo de cache do Preflight em segundos (padrão: 86400)
HTTP_FLOW_MAX_AGE=3600

# Permitir Cookies/Credenciais (true/false)
HTTP_FLOW_ALLOW_CREDENTIALS=true

use Codebr\HttpFlow\Response;

$response = new Response();

// Retorno JSON com Status Code 201
$response->json(['message' => 'Criado com sucesso'], 201)->send();

// Retorno HTML
$response->html('Bem-vindo')->send();

use Codebr\HttpFlow\Request;
use Codebr\HttpFlow\Response;

$request = new Request();

if ($request->getMethod() === 'OPTIONS') {
    (new Response())->options()->send();
    exit;
}

use Codebr\HttpFlow\Request;
use Codebr\HttpFlow\Response;

$request = new Request();

if ($request->getMethod() === 'OPTIONS') {
    (new Response())->options()->send();
    exit;
}

$request = new \Codebr\HttpFlow\Request();

// Pega dados do JSON ou POST de forma segura
$data = $request->only(['email', 'username']);

// Busca um campo específico com fallback
$search = $request->input('search', 'default_term');

Gestão de CORS (Preflight)
Para resolver requisições OPTIONS automaticamente usando as configurações do seu .env:

if ($request->isPreflight()) {
    (new Response())->options()->send();
    exit;

Testabilidade

$request = new Request(
    server: ['REQUEST_METHOD' => 'POST'],
    body: ['user' => 'test']
);
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance74

Regular maintenance activity

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity34

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 ~0 days

Total

2

Last Release

148d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4ed3f035abc9c5062b79786be702dcb5ad04dd28fcc7cdb097fac51c1afde548?d=identicon)[thiagopinto](/maintainers/thiagopinto)

---

Top Contributors

[![thiagopinto](https://avatars.githubusercontent.com/u/647523?v=4)](https://github.com/thiagopinto "thiagopinto (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[react/http

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

78026.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48347.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)

PHPackages © 2026

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