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

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

cook/http
=========

Defines an object-oriented layer for the HTTP specification.

00PHPCI passing

Since Mar 2Pushed 1y agoCompare

[ Source](https://github.com/CookAPI/Http)[ Packagist](https://packagist.org/packages/cook/http)[ RSS](/packages/cook-http/feed)WikiDiscussions main Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

HTTP Library
============

[](#http-library)

The HTTP Library is a versatile PHP toolkit designed to facilitate the handling of HTTP requests and responses in web applications. It offers a clear and efficient way to manage request data, middleware operations, response generation, and much more.

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

[](#installation)

To add the HTTP Library to your project, use Composer, the PHP package manager. First, ensure Composer is installed in your project. If not, follow the installation instructions at [getcomposer.org](https://getcomposer.org/download/). Then, run the following command in your project root:

```
composer require cook/http
```

This command will install the HTTP Library and its dependencies into your project, making it ready for use.

Using Middleware
----------------

[](#using-middleware)

Middleware allows you to perform actions or checks on the HTTP request and response cycle. This feature is useful for tasks like logging, authentication, or modifying the request/response objects.

### Example Middleware: LoggingMiddleware

[](#example-middleware-loggingmiddleware)

```
namespace Cook\Component\Http;

class LoggingMiddleware implements Middleware
{
    public function handle(Request $request, callable $next): Response
    {
        error_log("Logging Request: " . $request->getRequestUri());
        $response = $next($request);
        error_log("Logging Response: " . $response->getStatusCode());

        return $response;
    }
}
```

### Middleware Usage

[](#middleware-usage)

```
$request = Request::createFromGlobals();
$stack = new MiddlewareStack();
$stack->addMiddleware(new LoggingMiddleware());

$response = $stack->handle($request);
$response->send();
```

File Upload Handling
--------------------

[](#file-upload-handling)

Handling file uploads securely and efficiently is crucial in many web applications. The HTTP Library simplifies this process.

### Handling a File Upload

[](#handling-a-file-upload)

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

// Assuming a form field named 'uploadedFile'
if ($request->file->has('uploadedFile')) {
    $file = $request->file->get('uploadedFile');
    $uploadPath = '/path/to/uploads';

    // Move the uploaded file
    if ($request->file->upload('uploadedFile', $file['name'], $uploadPath)) {
        echo "File uploaded successfully.";
    } else {
        echo "File upload failed.";
    }
}
```

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

[](#contributing)

We welcome contributions to the HTTP Library! Feel free to submit pull requests or issues through our GitHub repository to suggest improvements or report bugs.

License
-------

[](#license)

The HTTP Library is open-source software licensed under the MIT license.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity18

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4672878?v=4)[CoreAPI](/maintainers/coreapi)[@coreapi](https://github.com/coreapi)

---

Top Contributors

[![PixeleeCode](https://avatars.githubusercontent.com/u/56721751?v=4)](https://github.com/PixeleeCode "PixeleeCode (3 commits)")

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/cook-http/health.svg)](https://phpackages.com/packages/cook-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.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)
