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

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

boubacamara/ganega-http
=======================

Provides simple and intuitive classes for handling HTTP requests and responses in PHP applications. The Request class encapsulates HTTP request data, making it easy to manage and access parameters, body, session, cookies, and server information. The Response class simplifies the creation and management of HTTP responses, allowing you to set content, status codes, and headers effortlessly.

1.0.0(2y ago)09MITPHPPHP ^8.2

Since Jun 23Pushed 2y ago1 watchersCompare

[ Source](https://github.com/boubacamara/ganega-http)[ Packagist](https://packagist.org/packages/boubacamara/ganega-http)[ RSS](/packages/boubacamara-ganega-http/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependenciesVersions (2)Used By (0)

Ganega\\Http
============

[](#ganegahttp)

The `Request` and `Response` classes provide simple and intuitive interfaces for handling HTTP requests and responses in your PHP application. They encapsulate request data and HTTP responses, making their manipulation and management easier.

Purpose
-------

[](#purpose)

The `Request` and `Response` classes are designed to simplify interaction with HTTP request and response data. They offer methods to check and retrieve request parameters, request body data, sessions, cookies, and server information, as well as to configure and send HTTP responses. This abstraction allows you to manipulate HTTP requests and responses cleanly and efficiently without directly accessing global variables like `$_GET`, `$_POST`, `$_SESSION`, `$_COOKIE`, `$_SERVER`, and `$_FILES`.

Ease of Use
-----------

[](#ease-of-use)

The `Request` and `Response` classes provide a clear and concise interface with well-defined methods for common HTTP request and response operations. Using these classes helps reduce repetitive code and makes the code more readable and maintainable.

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

[](#installation)

To use these classes in your project, simply include them in your PSR-4 autoloader or directly import them into your PHP file.

```
composer require boubacamara/ganega-http
```

Usage Examples
--------------

[](#usage-examples)

### Request Class

[](#request-class)

#### Create a `Request` instance from global variables

[](#create-a-request-instance-from-global-variables)

```
use Ganega\Http\Request\Request;

$request = Request::fromGlobals();
```

##### Check if the request has a body

[](#check-if-the-request-has-a-body)

```
if ($request->hasBody()) {
    // Process the request body
}
```

##### Get the request body

[](#get-the-request-body)

```
$body = $request->getBody();
```

##### Check and retrieve a request parameter

[](#check-and-retrieve-a-request-parameter)

```
if ($request->hasInput('username')) {
    $username = $request->getInput('username');
}
```

##### Manipulate sessions

[](#manipulate-sessions)

```
// Add a session
$request->addSession('user_id', 123);

// Retrieve a session
$user_id = $request->getSession('user_id');

// Delete a session
$request->deleteSession('user_id');

// Destroy all sessions
$request->destroySession();
```

##### Manipulate cookies

[](#manipulate-cookies)

```
// Add a cookie
$request->addCookie('test_cookie', 'value', ['expires' => time() + 3600]);

// Retrieve a cookie
$cookieValue = $request->getCookie('test_cookie');

// Delete a cookie
$request->destroyCookie('test_cookie');
```

##### Retrieve URL and server information

[](#retrieve-url-and-server-information)

```
// Get the URL path
$urlPath = $request->getUrlPath();

// Get the full URL
$url = $request->getUrl();

// Check the request method
if ($request->hasMethod('POST')) {
    // Process the POST request
}

// Get the request method
$method = $request->getMethod();

// Get the script name
$scriptName = $request->getScriptName();

// Get the server scheme (HTTP/HTTPS)
$serverScheme = $request->getServerScheme();

// Get the host
$host = $request->getHost();

// Get the server port
$port = $request->getPort();

// Check and get the server referrer
if ($request->hasServerReferer()) {
    $referer = $request->getServerReferer();
}
```

##### Parse the request body

[](#parse-the-request-body)

```
$parsedBody = $request->bodyParser();
```

### Response Class

[](#response-class)

#### Create a `Response` instance

[](#create-a-response-instance)

```
use Ganega\Http\Request\Response;

$response = new Response();
```

##### Set the response content

[](#set-the-response-content)

```
$response->setContent('Hello, World!');
```

##### Add content to the existing response

[](#add-content-to-the-existing-response)

```
$response->addContent(' More content.');
```

##### Set an HTTP header

[](#set-an-http-header)

```
$response->setHeader('Content-Type', 'application/json');
```

##### Set the HTTP status code

[](#set-the-http-status-code)

```
$response->setStatusCode(404);
```

##### Send the response

[](#send-the-response)

```
echo $response->send();
```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

741d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/173595159?v=4)[Boubacar CAMARA](/maintainers/boubacamara)[@boubacamara](https://github.com/boubacamara)

---

Top Contributors

[![boubacamara](https://avatars.githubusercontent.com/u/173595159?v=4)](https://github.com/boubacamara "boubacamara (6 commits)")

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/boubacamara-ganega-http/health.svg)](https://phpackages.com/packages/boubacamara-ganega-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.9M7.0k](/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)
