mobypolo / roadrunner-lumen by mobypolo

RoadRunner Lumen Integration Bridge
4,205
1
1
Package Data
Maintainer Username: mobypolo
Maintainer Contact: to@mobypolo.com (Moby Polo)
Package Create Date: 2021-07-21
Package Last Update: 2022-07-07
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-04-19 15:07:11
Package Statistics
Total Downloads: 4,205
Monthly Downloads: 112
Daily Downloads: 2
Total Stars: 1
Total Watchers: 1
Total Forks: 1
Total Open Issues: 1

RoadRunnerLumen bridge

License

Easy way for connecting RoadRunner and Lumen applications.

🐋 If you want to see an example of a laravel application in a docker container with RoadRunner as a web server - take a look at this repository.

Installation

Make sure that RR binary file already installed on your system (or docker image). Require this package with composer using next command:

$ composer require mobypolo/roadrunner-lumen

Installed composer is required (how to install composer).

Usage

After package installation place .rr.yaml config in your work directory, simple .rr.yaml config example (full example can be found here):

rpc:
  listen: tcp://127.0.0.1:6001

server:
  command: "php /app/vendor/mobypolo/roadrunner-lumen/bin/rr-lumen-worker" # maybe you need to update this path

http:
  address: 0.0.0.0:8080
  middleware: ["headers", "gzip"]
  pool:
    max_jobs: 4 # feel free to change this
  headers:
    response:
      X-Powered-By: "RoadRunner"

Roadrunner server starting:

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

Known issues

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:

<?php

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
    /**
     * The user repository instance.
     */
    protected $users;

    /**
     * @var Request
     */
    protected $request;

    /**
     * @param UserRepository $users
     * @param Request        $request
     */
    public function __construct(UserRepository $users, Request $request)
    {
        $this->users   = $users;
        $this->request = $request;
    }

    /**
     * @return Response
     */
    public function store(): Response
    {
        $user = $this->users->getById($this->request->id);

        // ...
    }
}

Good:

<?php

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
    /**
     * @param  Request        $request
     * @param  UserRepository $users
     *
     * @return Response
     */
    public function store(Request $request, UserRepository $users): Response
    {
        $user = $users->getById($request->id);

        // ...
    }
}

Support

If you find any package errors, please, make an issue in a current repository.

License

MIT License (MIT). Please see LICENSE for more information. Fully inspired by eplightning and Spiral Scout.