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

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

dezworkastronphp/http
=====================

http request and response solutions

v0.0.7(3y ago)04MITPHPPHP ^7.0

Since May 4Pushed 3y ago1 watchersCompare

[ Source](https://github.com/dezworkastronphp/http)[ Packagist](https://packagist.org/packages/dezworkastronphp/http)[ RSS](/packages/dezworkastronphp-http/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

Http
====

[](#http)

[![](https://camo.githubusercontent.com/adcdc66751b636e32c86f89db1ecd19d639982a14383eed19e8f6fd89f2a7aca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617374726f6e7068702f687474702e737667)](https://packagist.org/packages/astronphp/http)[![](https://camo.githubusercontent.com/0dd1b2e4698f3c93e3d5f82e1166b306b34fc11653d1dcc10d66ae0c1dc8207c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617374726f6e7068702f687474702e737667)](https://packagist.org/packages/astronphp/http)[![](https://camo.githubusercontent.com/0ed7d60c27c668235a839a12dc20778af9255cdc6871863814bae8f350085f6f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f617374726f6e7068702f687474702e737667)](https://raw.githubusercontent.com/astronphp/http/master/LICENSE)[![](https://camo.githubusercontent.com/6a7b2e456ee951a28190df8893ded3be5e3bec8d182358cdc1e17030142569bf/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f617374726f6e7068702f687474702e737667)](https://travis-ci.org/astronphp/http)[![](https://camo.githubusercontent.com/9f144b8076bad522e2c04e0d752150a7d9f970c9be1a13d39a68549c0fcaeb9e/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f617374726f6e7068702f687474702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/astronphp/http)[![](https://camo.githubusercontent.com/452d4841c97b22097b518988b9376e7e9a76242125f7015378c636c80fbc423e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f617374726f6e7068702f687474702e737667)](https://github.com/astronphp/http/issues)[![](https://camo.githubusercontent.com/fe3411338e004bee71442d7bc045d1915348f334f51367d27743c271128c749b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f617374726f6e7068702f687474702e737667)](https://github.com/astronphp/http/graphs/contributors)

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

[](#instalação)

`composer require astronphp/http`

Guia do Usuário
---------------

[](#guia-do-usuário)

### 1. Enviando Requisições

[](#1-enviando-requisições)

#### 1.1 Configuração Inicial

[](#11-configuração-inicial)

```
use \Astronphp\Http\Request;

$request = new Request('www.example.com/api');
```

#### 1.2 Realizando Requisições

[](#12-realizando-requisições)

```
$request->post('/users');
$request->get('/users/1');
$request->put('/users/1');
$request->patch('/users/1');
$request->delete('/users/1');
```

#### 1.3 Enviando um Cabeçalho

[](#13-enviando-um-cabeçalho)

```
use \Astronphp\Http\Header;

$header = new Header();
$header->add('Content-Type', 'application/json');
// ou usando constantes
// $header->add(Header::CONTENT_TYPE, Request::JSON);

$request->get('/users/1', $header);
```

#### 1.4 Enviando um Corpo

[](#14-enviando-um-corpo)

##### 1.4.1 Utilizando um array

[](#141-utilizando-um-array)

```
$header = new Header();
$header->add('Content-Type', 'application/x-www-form-urlencoded');
//$header->add(Header::CONTENT_TYPE, Request::URL_ENCODED);

// enviando o corpo como array
$body = ['name' => 'Lorem Ipsum', 'document' => '123.456.789-12'];
$request->post('/users', $header, $body);
```

##### 1.4.2 Utilizando uma string json

[](#142-utilizando-uma-string-json)

```
$header = new Header();
$header->add('Content-Type', 'application/json');
//$header->add(Header::CONTENT_TYPE, Request::JSON);

$body = '{"name":"Lorem Ipsum", "document":"123.456.789-12"}';
$request->post('/users', $header, $body);
```

#### 1.5 Enviando parâmetros pela url

[](#15-enviando-parâmetros-pela-url)

```
$request->set('department', 'clothing');
$request->set('sort', 'best_seller');

// www.example.com/api/products/clothing?sort=best_seller
$request->get('/products/{department}');
```

Também pode ser fornecido um array associativo, o que produz o mesmo resultado que o exemplo anterior.

```
$request->set(['department' => 'clothing', 'sort' => 'best_seller']);
$request->get('/products/{department}');
```

#### 1.6 Recebendo dados da resposta

[](#16-recebendo-dados-da-resposta)

Vamos assumir que o exemplo abaixo retorna a seguinte estrutura:

```
 {
	"status":"success",
	"data": {
		"id": 1,
		"name": "Astron",
		"username": "astronphp",
		"password": "@astronphp"
	}
}
```

```
$response = $request->get('/users/1');

$response->getHttpCode(); // 200

$response->get('status'); // success
$response->get('data.name'); // Astron
```

### 2. Recebendo Requisições

[](#2-recebendo-requisições)

#### 2.1 Configuração Inicial

[](#21-configuração-inicial)

```
use \Astronphp\Http\Request;

$request = new Request();
```

#### 2.2 Acessando dados

[](#22-acessando-dados)

```
$request->query('username'); // dados recebidos via get
$request->body('username'); // dados recebidos via post
$request->files('picture');
$request->server('request_uri'); // case insensitive
$request->header('content_type'); // case insentitive
```

### 3. Enviando uma resposta

[](#3-enviando-uma-resposta)

#### 3.1 Configuração Inicial

[](#31-configuração-inicial)

```
use \Astronphp\Http\Response;

$response = new Response(['status' => 'success', 'message' => 'lorem ipsum']);

// ou como uma string json
// $response = new Response({"status":"success", "message":"lorem ipsum"});
```

### 3.2 Enviando uma resposta JSON

[](#32-enviando-uma-resposta-json)

```
$response->json();
```

### 4. Navegação entre páginas

[](#4-navegação-entre-páginas)

#### 4.1 Configurando uma URI base

[](#41-configurando-uma-uri-base)

```
\Astronphp\Http\Location::setBaseUri('https://www.example.com');
```

#### 4.2 Redirecionando

[](#42-redirecionando)

```
$location = new \Astronphp\Http\Location('/products');
$location->redirect(); // redireciona para https://www.example.com/products
```

#### 4.3 Recarregando a página

[](#43-recarregando-a-página)

```
$location = new \Astronphp\Http\Location();
$location->reload();
```

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

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

1156d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/889890f3ed04be33fc2f778ef8fba7cb620183d1046b348be7c45ca1c9429188?d=identicon)[astronphp](/maintainers/astronphp)

---

Top Contributors

[![dezworkastronphp](https://avatars.githubusercontent.com/u/132532601?v=4)](https://github.com/dezworkastronphp "dezworkastronphp (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M82](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k24.3k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k114](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M90](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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