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 1mo ago

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

Maintenance36

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity17

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://www.gravatar.com/avatar/cc929689022cd317431f6d9888d0851925265c390170f38522df18b851e9d134?d=identicon)[coreapi](/maintainers/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

[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)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[react/http

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

78026.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48347.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)

PHPackages © 2026

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