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 today

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

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

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

792d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/108286928?v=4)[Virag Rajput](/maintainers/viragrajput)[@ViragRajput](https://github.com/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

[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.4M92](/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)
