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

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

aviyandev/http
==============

A simple HTTP Foundation component

v1.0.0(1y ago)04MITPHP

Since Apr 11Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

AviyanDev HTTP
==============

[](#aviyandev-http)

A lightweight, modern PHP HTTP abstraction package inspired by Symfony HttpFoundation — with zero third-party dependencies. Supports PSR-7, PSR-15, fluent API, middleware, and custom HTTP exceptions.

---

Features
--------

[](#features)

- PSR-7 compatible Request &amp; Response classes
- PSR-15 Middleware support
- Fluent API for building responses
- Immutable request object design
- Custom HTTP Exceptions (404, 401, 403, etc.)
- No external dependencies
- Cookie and Session management
- File uploads handling
- JSON response helpers
- Stream abstraction

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

[](#installation)

```
composer require aviyandev/http
```

Basic Usage
-----------

[](#basic-usage)

### Creating a Response

[](#creating-a-response)

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

// Basic response
$response = new Response('Hello World', 200);

// JSON response
$response = new JsonResponse(['message' => 'Success']);

// Redirect response
$response = new RedirectResponse('/dashboard');
```

### Handling Requests

[](#handling-requests)

```
use Http\Request;

// Get current request
$request = Request::createFromGlobals();

// Access request data
$id = $request->query->get('id');
$token = $request->headers->get('Authorization');
$data = $request->request->all(); // POST data
```

### Working with Middleware

[](#working-with-middleware)

```
use Http\Middleware\MiddlewareInterface;

class AuthMiddleware implements MiddlewareInterface
{
    public function process(Request $request, callable $next)
    {
        if (!$request->headers->has('Authorization')) {
            return new Response('Unauthorized', 401);
        }

        return $next($request);
    }
}
```

### File Uploads

[](#file-uploads)

```
$file = $request->files->get('document');

if ($file->isValid()) {
    $file->move('/uploads', 'new-filename.pdf');
}
```

### Session Handling

[](#session-handling)

```
use Http\Session;

$session = new Session();
$session->start();

$session->set('user_id', 123);
$userId = $session->get('user_id');
```

API Reference
-------------

[](#api-reference)

### Response Class

[](#response-class)

- `setContent(string $content)`: Set response content
- `setStatusCode(int $code)`: Set HTTP status code
- `headers->set(string $key, string $value)`: Set response header
- `send()`: Send the response

### Request Class

[](#request-class)

- `query`: GET parameters
- `request`: POST parameters
- `headers`: Request headers
- `cookies`: Cookie parameters
- `files`: Uploaded files
- `getMethod()`: Get HTTP method
- `getUri()`: Get request URI

### JsonResponse Class

[](#jsonresponse-class)

- `setData(array $data)`: Set JSON data
- `withEncoding(int $options)`: Set JSON encoding options

### Stream Class

[](#stream-class)

- `write(string $data)`: Write to stream
- `read(int $length)`: Read from stream
- `getContents()`: Get remaining contents
- `getSize()`: Get stream size

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance46

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

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

Unknown

Total

1

Last Release

402d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5bcc09bf6856ea999081c782fcefa350bcae89f459c4ca4bd628a130d5bcac80?d=identicon)[aviyandev](/maintainers/aviyandev)

---

Top Contributors

[![aviyandev](https://avatars.githubusercontent.com/u/39535998?v=4)](https://github.com/aviyandev "aviyandev (1 commits)")

### Embed Badge

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

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

###  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)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

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

78126.4M414](/packages/react-http)

PHPackages © 2026

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