PHPackages                             mbarquin/reactphp-slim - 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. [Framework](/categories/framework)
4. /
5. mbarquin/reactphp-slim

ActiveLibrary[Framework](/categories/framework)

mbarquin/reactphp-slim
======================

Slim Request and Response extended to allow reactPHP serve a Slim framework instance

v0.4.3(9y ago)222477[3 issues](https://github.com/mbarquin/reactphp-slim/issues)[3 PRs](https://github.com/mbarquin/reactphp-slim/pulls)MITPHPPHP ^7.0

Since Jul 13Pushed 8y ago3 watchersCompare

[ Source](https://github.com/mbarquin/reactphp-slim)[ Packagist](https://packagist.org/packages/mbarquin/reactphp-slim)[ RSS](/packages/mbarquin-reactphp-slim/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

reactphp-slim
=============

[](#reactphp-slim)

Introduction
------------

[](#introduction)

This library is created in order to use reactPHP as a HTTP server for Slim framework. It will launch a Slim\\App process when a request is made, and at the same time it will transfer data from reactPHP native objects into Slim objects. With this, we will be able to create a basic react server for a Slim framework application.

Data, cookies and file uploads transmission between react and Slim objects. You can access through slim native functions to uploaded files, data and cookies.

\##Installation You can install the component in the following ways:

- Use the official Github repository ()
- Use composer : composer require mbarquin/reactphp-slim --dev

\##Usage After the composer autoload requirement a Slim\\App should be instanced and prepared as usual. Slim\\App can be bootstrapped and all dependencies can be injected as you like, after that, a reactphp-slim server should be instanced and call the run method in it, using slim\\App as parameter. The reactphp-slim server will act as intermediary and will launch the slim application through the `process` method when requested, this method avoids the usual request and response bootstrap made by Slim.

When uploading files, move\_uploaded\_files() probably won't work, use native object methods to move the file.

```
require '../vendor/autoload.php';

use \mbarquin\reactSlim;

// We keep a new Slim app instance.
$app = new \Slim\App();

// We add a closure to attend defined request routes
$app->any('/hello/{name}', function (
        \Slim\Http\Request $request,
        \Slim\Http\Response $response) {

        $name = $request->getAttribute('name');

        $response->getBody()->write("Hello, $name");
        $response->getBody()->write(print_r($request->getParsedBody(), true));
        $response->getBody()->write(print_r($request->getCookieParams(), true));
        $response->getBody()->write(print_r($request->getHeaders(), true));
        // $response->getBody()->write(print_r($request->getUploadedFiles(), true));

        return $response;
    });

$server = new \mbarquin\reactSlim\Server();

$server->withHost('192.168.67.1')->withPort(1337)->run($app);
```

\\mbarquin\\reactSlim\\Server object is the class which is going to configure and launch a ReactPHP server. It has two main methods

**withHost($string)**Sets the IP to be listened to

**withPort($int)**Sets the port the server will be listening to, by default it will be set to 1337.

**run(\\Slim\\App $app)**It launches the server process and wait until a request is made to launch the \\Slim\\App passed as parameter.

### v0.4.2 Setup

[](#v042-setup)

This is the old setup to run the reactPHP server with a slimPHP application

```
require '../vendor/autoload.php';

use mbarquin\reactSlim;

// We keep a new Slim app instance.
$app = new \Slim\App();

// We add a closure to listen defined request routes
$app->get('/hello/{name}', function (
        \mbarquin\reactSlim\Request $request,
        \mbarquin\reactSlim\Response $response) {

        $name = $request->getAttribute('name');
        $response->getBody()->write("Hello, $name");

        return $response;
    });

// We create a closure to be attached to server request event.
$serverCallback = function (
       \React\Http\Request $request,
       \React\Http\Response $response) use ($app){

    $slRequest  = \mbarquin\reactSlim\Request::createFromReactRequest($request);
    $slResponse = new \mbarquin\reactSlim\Response();

    $app->process($slRequest, $slResponse);

    $slResponse->setReactResponse($response, true);
};

// We make the setup of the ReactPHP
$loop   = React\EventLoop\Factory::create();
$socket = new React\Socket\Server($loop);
$http   = new React\Http\Server($socket, $loop);

// Ligamos la closure al evento request.
$http->on('request', $serverCallback);

echo "Server running at http://127.0.0.1:1337\n";

$socket->listen(1337);
$loop->run();
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity51

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

Every ~39 days

Total

4

Last Release

3520d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e374f8ad1775a2991c6662869ca1b6e7b3693b434404b6f77ddce0238a7abea8?d=identicon)[mbarquin](/maintainers/mbarquin)

---

Top Contributors

[![mbarquin](https://avatars.githubusercontent.com/u/6476519?v=4)](https://github.com/mbarquin "mbarquin (19 commits)")

### Embed Badge

![Health badge](/badges/mbarquin-reactphp-slim/health.svg)

```
[![Health](https://phpackages.com/badges/mbarquin-reactphp-slim/health.svg)](https://phpackages.com/packages/mbarquin-reactphp-slim)
```

###  Alternatives

[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

42.9k337.6k1](/packages/ccxt-ccxt)[zubzet/framework

 A lightweight PHP framework focused on rapid development, ease of use, and great portability.

1370.1k1](/packages/zubzet-framework)[vesp/core

Vesp core library to make backend simple

243.9k5](/packages/vesp-core)[duxweb/dux-lite

The lightweight framework based on slim php

161.0k9](/packages/duxweb-dux-lite)

PHPackages © 2026

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