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

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

viragrajput/http-foundation
===========================

A lightweight HTTP foundation package for PHP.

v1.0.0(2y ago)0151MITPHPPHP ^7.4 || ^8.0

Since May 3Pushed 2y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (2)Versions (2)Used By (1)

Virag HTTPFoundation
====================

[](#virag-httpfoundation)

HTTPFoundation is a PHP package designed to provide a set of classes for handling HTTP-related tasks, including handling cookies, sessions, file uploads, generating HTTP responses, and processing HTTP requests. This package aims to simplify common HTTP-related operations in PHP web development.

Features
--------

[](#features)

- **Cookie Handling**: Easily manage HTTP cookies with the `Cookie` class, including setting, getting, deleting, and encrypting/decrypting cookie values.
- **Session Management**: Handle PHP sessions effortlessly with the `Session` class, allowing setting, getting, checking existence, and removing session data.
- **File Upload Handling**: Manage file uploads with the `UploadedFile` class, including retrieving file information, moving uploaded files, and determining file types.
- **HTTP Response Generation**: Generate HTTP responses dynamically with the `Response` class, allowing setting status codes, headers, and response content easily.
- **HTTP Request Processing**: Process incoming HTTP requests with the `Request` class, enabling access to request headers, parameters, and files.

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

[](#installation)

You can install the HTTPFoundation package via [Composer](https://getcomposer.org/):

```
composer require viragrajput/http-foundation
```

Usage
-----

[](#usage)

### Cookie Handling

[](#cookie-handling)

```
use Virag\HttpFoundation\Cookie;

// Set a cookie
Cookie::set('username', 'john_doe', time() + 3600, '/', 'example.com', true, true);

// Get a cookie value
$username = Cookie::get('username');

// Delete a cookie
Cookie::delete('username');
```

### Session Management

[](#session-management)

```
use Virag\HttpFoundation\Session;

// Start a session
$session = new Session();

// Set session data
$session->set('user_id', 123);

// Get session data
$userID = $session->get('user_id');

// Regenerate session ID
$session->regenerateId();
```

### File Upload Handling

[](#file-upload-handling)

```
use Virag\HttpFoundation\UploadedFile;

// Handle file upload
$file = new UploadedFile(
    $_FILES['file']['name'],
    $_FILES['file']['type'],
    $_FILES['file']['tmp_name'],
    $_FILES['file']['error'],
    $_FILES['file']['size']
);

// Move uploaded file to destination directory
$file->move('uploads/');
```

For more details example of this class, please check docs folder.

### HTTP Response Generation

[](#http-response-generation)

```
use Virag\HttpFoundation\Response;

// Create a response with JSON content
$response = new Response();
$response->setJsonResponse(['message' => 'Success'], 200);
$response->send();

// Create a response with HTML content
$htmlContent = "Hello, World!";
$response = new Response();
$response->setHtmlResponse($htmlContent, 200);
$response->send();

// Create a redirect response
$response = new Response();
$response->setRedirectResponse('/new-page', 302);
$response->send();

// Create a response with custom headers
$response = new Response();
$response->setHtmlResponse('Custom Content', 200);
$response->setHeader('X-Custom-Header', 'Value');
$response->send();

// Create a response with an error message
$response = new Response();
$response->setBadRequestResponse('Bad Request');
$response->send();
```

### HTTP Request Processing

[](#http-request-processing)

The `createFromGlobals` method creates a `Request` object based on the global variables available in PHP, such as `$_SERVER`, `$_REQUEST`, and `php://input`. This method is convenient for creating request objects in a standardized way, especially in web applications where requests are typically handled through the global scope.

```
use Virag\HttpFoundation\Request;

// Create a request object from global variables
$request = Request::createFromGlobals();

// Now you can access various properties and methods of the $request object
$method = $request->getMethod();
$uri = $request->getUri();
$params = $request->getParameters();
$headers = $request->getHeaders();
```

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

[](#contributing)

Contributions are welcome! Feel free to open an issue or submit a pull request for any improvements or bug fixes.

License
-------

[](#license)

This package is open-source software licensed under the [MIT License](LICENSE).

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

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

Unknown

Total

1

Last Release

737d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dad689e5f68ca906d4ac7685da9de4ecbd6703ce6dc4e690c95fe4f8aa817fea?d=identicon)[viragrajput](/maintainers/viragrajput)

---

Top Contributors

[![ViragRajput](https://avatars.githubusercontent.com/u/108286928?v=4)](https://github.com/ViragRajput "ViragRajput (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[friendsofsymfony/rest-bundle

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

2.8k73.3M317](/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.8M292](/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)
