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

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

slick/http
==========

Slick/Http is an useful library for Web application foundation. It implements the PSR-7 message interface and has a middleware server, session handling and an HTTP client.

v4.0.2(6mo ago)18.0k—4.3%6MITPHPPHP &gt;=8.2CI failing

Since Jan 30Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/slickframework/http)[ Packagist](https://packagist.org/packages/slick/http)[ Docs](https://github.com/slickframework/http)[ RSS](/packages/slick-http/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (8)Versions (21)Used By (6)

Slick HTTP
==========

[](#slick-http)

[![Latest Version on Packagist](https://camo.githubusercontent.com/02453eacd56e92378d579adfb8201bbdf1a4036386710a4dbf761d6c9111d9f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736c69636b2f687474702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/slick/http)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Quality Score](https://camo.githubusercontent.com/4824447d16bac2bc856fcdbc37d66fbb3df6210e83e483e38c2f469afce558fe/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f736c69636b6672616d65776f726b2f687474702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/slickframework/http)[![Total Downloads](https://camo.githubusercontent.com/20b4500e1d9cc644169f03a127be33c006570deac92cdce4497af00b2b9db88b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736c69636b2f687474702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/slickframework/http)

`slick/http` provides a complete implementation of PSR-7 (HTTP Message Interface) and PSR-18 (HTTP Client Interface), enabling developers to work seamlessly with HTTP messages and clients in a standardized way. By adhering to these PSR standards, the library ensures interoperability with other libraries and frameworks that follow the same specifications, promoting code reusability and consistency across projects. In addition, the library includes an HTTP server that functions as a middleware runner, allowing you to pass a collection of middleware objects to the server, which are called in sequence to compose a response for the current server request. This middleware approach provides a flexible, modular way to handle HTTP requests, enhancing the scalability and maintainability of your PHP applications.

This package is compliant with PSR-2 code standards and PSR-4 autoload standards. It also applies the [semantic version 2.0.0](http://semver.org) specification.

Install
-------

[](#install)

Via Composer

```
$ composer require slick/http
```

Usage
-----

[](#usage)

### Server Request Message

[](#server-request-message)

This is an handy way to have a HTTP request message that has all necessary information that was sent by the client to the server.

Its very simple to get this:

```
use Slick\Http\Message\Server\Request;

$request = new Request();
```

The `$request` encapsulates all data as it has arrived at the application from the CGI and/or PHP environment, including:

- The values represented in $\_SERVER.
- Any cookies provided (generally via $\_COOKIE)
- Query string arguments (generally via $\_GET, or as parsed via parse\_str())
- Upload files, if any (as represented by $\_FILES)
- Deserialized body parameters (generally from $\_POST)

Consider the following message:

```
POST /path?_goto=home HTTP/1.1
Host: www.example.org
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Content-Lenght: 5
Authorization: Bearer PAOIPOI-ASD9POKQWEL-KQWELKAD==

foo=bar&bar=baz
```

Now lest retrieve its information using the `$request` object:

```
echo $request->getHeaderLine('Authorization');  // will print "Bearer PAOIPOI-ASD9POKQWEL-KQWELKAD=="

print_r($request->getParsedBody());
# Array (
#   [foo] => bar,
#   [bar] => baz
#)

print_r($request->getQueryParam());
# Array (
#   [_goto] => home
#)
```

### HTTP Server

[](#http-server)

The HTTP server is a middleware runner. You can pass a collection of middleware objects to the server and they all will be called in their sequence in order to compose a response for current server request.

Lets create a simple web application that will print out a greeting to a query parameter named 'name'. Lets first create our middleware classes:

```
use Psr\Http\Server\MiddlewareInterface;
use Interop\Http\Server\RequestHandlerInterface;

class Greeting implements MiddlewareInterface
{

    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler)
    {
        $params = $request->getQueryParams();
        $request = (isset($params['name'])
            ? $request->withAttribute('greeting', "Hello, {$params['name']}!")
            : $request;

        $response = $handler->handle($request);
        return $response;
    }
}
```

This middleware retrieves the query parameter with name and add an attribute to the request object passed to the next middleware in the stack. Lets create our printer:

```
use Psr\Http\Server\MiddlewareInterface;
use Interop\Http\Server\RequestHandlerInterface;

class Printer implements MiddlewateInterface
{

    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler)
    {
      $greeting = $request->getAttribute('greeting', false);
      $text = $greeting ?: 'Hi!';

      $response = $handler->handle($request);

      $response->getBody()->write($text);

      return $response;
    }
}
```

Now lets create our main server application:

```
use Slick\Http\Server\MiddlewareStack;
use Slick\Http\Message\Response;
use Slick\Http\Message\Server\Request;

$stack = (new MiddlewareStack())
    ->push(new Greeting())
    ->push(new Printer())
    ->push(function () { return new Response(200); }); // Order matters!

$response = $stack->process(new Request);

// Emit headers iteratively:
foreach ($response->getHeaders() as $name => $values) {
    header(sprintf('%s: %s', $name, implode(', ', $value)), false);
}

// Print out the message body
echo $response->getBody();
```

### HTTP Client

[](#http-client)

Working with HTTP requests (as a client) is one of the most common tasks nowadays. Almost every application need to retrieve data from a web service or API and therefore an HTTP client is a must have.

`Slick\Http\Client\CurlHttpClient` implments [PSR-18 HTTP Client](https://www.php-fig.org/psr/psr-18/)

```
public function sendRequest(RequestInterface $request): ResponseInterface;
```

It depends on PHP's `cURL` extension to connect and make HTTP requests. Lets see an example:

```
use Psr\Http\Message\ResponseInterface;
use Slick\Http\Client\CurlHttpClient;
use Slick\Http\Message\Request;
use Slick\Http\Message\Uri;

$request = new Request('GET', new Uri('https://example.com'));
$client = new CurlHttpClient();

$response = $client->sendRequest($request);

$data = json_decode($response->getBody()->getContents());
```

### Session

[](#session)

`Slick\Http\Session` has a very simple and ease implementation. By default it will use the PHP session handling and it comes with a simple factory that you can use to create it:

```
use Slick\Http\Session;

$session = Session::create();
```

##### Write session data

[](#write-session-data)

```
$session->set('foo', 'bar');
```

##### Read session data

[](#read-session-data)

```
$session->read('foo', null); // if foo is not found the default (null) will be returned.
```

##### Deleting session data

[](#deleting-session-data)

```
$session->erase('foo');
```

You can create your own session drivers if you need to encrypt you data or change the save handler to save in a database by simply implementing the `Slick\Http\Session\SessionDriverInterface`. It also comes with a `Slick\Http\Session\Driver\AbstractDriver` class that has all the basic operations of the interface already implemented.

Please check [documentation site](https://http.slick-framework.com) for a complete reference.

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [All Contributors](https://github.com/slickframework/http/graphs/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance67

Regular maintenance activity

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 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

Every ~226 days

Recently: every ~516 days

Total

17

Last Release

193d ago

Major Versions

v1.2.3 → v2.0.0-RC12017-11-05

v2.1.0 → v3.0.22020-11-18

v3.0.3 → v4.0.02025-11-03

PHP version history (2 changes)v2.1.0PHP &gt;=7.2

v4.0.0PHP &gt;=8.2

### Community

Maintainers

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

---

Top Contributors

[![silvamfilipe](https://avatars.githubusercontent.com/u/5720969?v=4)](https://github.com/silvamfilipe "silvamfilipe (105 commits)")

---

Tags

psr-18psr-7sessionslick-phphttprequestpsr-7clientpsr-18psr-15slick

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.1B4.0k](/packages/guzzlehttp-psr7)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[mezzio/mezzio

PSR-15 Middleware Microframework

3923.8M126](/packages/mezzio-mezzio)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

185702.8k44](/packages/laudis-neo4j-php-client)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)

PHPackages © 2026

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