PHPackages                             pushrbx/lumen-roadrunner - 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. pushrbx/lumen-roadrunner

ActiveLibrary

pushrbx/lumen-roadrunner
========================

Lumen framework on RoadRunner

v5.9.1(3y ago)124MITPHPPHP ^8.0

Since May 22Pushed 3y agoCompare

[ Source](https://github.com/pushrbx/lumen-roadrunner)[ Packagist](https://packagist.org/packages/pushrbx/lumen-roadrunner)[ RSS](/packages/pushrbx-lumen-roadrunner/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (14)Versions (24)Used By (0)

Lumen framework on RoadRunner
=============================

[](#lumen-framework-on-roadrunner)

Easy way for connecting [RoadRunner](https://github.com/roadrunner-server/roadrunner) and [Lumen](https://lumen.laravel.com) applications. This is a fork of [spiral/roadrunner-laravel](https://github.com/spiral/roadrunner-laravel), which makes it work with lumen instead of the full laravel framework.

> Please note that this lib is not production ready yet, it's under development.

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

[](#installation)

Make sure that [RR binary file](https://github.com/roadrunner-server/roadrunner/releases) already installed on your system (or docker image). Require this package with composer using next command:

```
$ composer require pushrbx/lumen-roadrunner
```

> Installed `composer` is required ([how to install composer](https://getcomposer.org/download/)).

After that you can "publish" package configuration file (`./config/roadrunner.php`) using next command:

```
$ php ./artisan vendor:publish --provider='pushrbx\LumenRoadRunner\ServiceProvider' --tag=config
```

**Important**: despite the fact that worker allows you to refresh application instance on each HTTP request *(if worker started with option `--refresh-app`, eg.: `php ./vendor/bin/rr-worker start --refresh-app`)*, we strongly recommend avoiding this for performance reasons. Large applications can be hard to integrate with RoadRunner *(you must decide which of service providers must be reloaded on each request, avoid "static optimization" in some cases)*, but it's worth it.

Usage
-----

[](#usage)

After package installation you can use provided "binary" file as RoadRunner worker: `./vendor/bin/rr-worker`. This worker allows you to interact with incoming requests and outgoing responses using [laravel events system](https://laravel.com/docs/events). Event contains:

Event classnameApplication objectHTTP server requestHTTP requestHTTP responseException`BeforeLoopStartedEvent`✔`BeforeLoopIterationEvent`✔✔`BeforeRequestHandlingEvent`✔✔`AfterRequestHandlingEvent`✔✔✔`AfterLoopIterationEvent`✔✔✔`AfterLoopStoppedEvent`✔`LoopErrorOccurredEvent`✔✔✔Simple `.rr.yaml` config example ([full example can be found here](https://github.com/roadrunner-server/roadrunner/blob/master/.rr.yaml)):

> For `windows` path must be full (eg.: `php vendor/pushrbx/lumen-roadrunner/bin/rr-worker start`)

```
version: "2.7"

server:
  command: "php ./vendor/bin/rr-worker start --relay-dsn unix:///var/run/rr-relay.sock"
  relay: "unix:///var/run/rr-relay.sock"

http:
  address: 0.0.0.0:8080
  middleware: ["static", "headers", "gzip"]
  pool:
    max_jobs: 64 # feel free to change this
    supervisor:
      exec_ttl: 60s
  headers:
    response:
      X-Powered-By: "RoadRunner"
  static:
    dir: "public"
    forbid: [".php"]
```

**Socket** or **TCP port** relay usage is strongly recommended for avoiding problems with `dd()`, `dump()`, `echo()` and other similar functions, that sends data to the IO pipes.

Roadrunner server starting:

```
$ rr serve -c ./.rr.yaml
```

### Listeners

[](#listeners)

This package provides event listeners for resetting application state without full application reload *(like cookies, HTTP request, application instance, service-providers and other)*. Some of them already declared in configuration file, but you can declare own without any limitations.

### Helpers

[](#helpers)

This package provides the following helpers:

NameDescription`\rr\dump(...)`Dump passed values (dumped result will be available in the HTTP response)`\rr\dd(...)`Dump passed values and stop the execution`\rr\worker()`Easy access to the RoadRunner PSR worker instance### Known issues

[](#known-issues)

#### Performance degradation

[](#performance-degradation)

...when `file` driver is set for your sessions. Please, use `redis` (or something similar) driver instead ([related issue](https://github.com/spiral/roadrunner-laravel/issues/23)). This package or/and RoadRunner has nothing to do with it, but since this is a fairly common issue - it is described here.

#### Controller constructors

[](#controller-constructors)

You should avoid to use HTTP controller constructors *(created or resolved instances in a constructor can be shared between different requests)*. Use dependencies resolving in a controller **methods** instead.

Bad:

```
