mobypolo / roadrunner-lumen
RoadRunner <-> Lumen Integration Bridge
Installs: 4 982
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 2
Open Issues: 1
Requires
- laravel/lumen-framework: ~8.0
- nyholm/psr7: ^1.1
- spiral/goridge: ^3.0
- spiral/roadrunner: ^2.0.0
- symfony/psr-http-message-bridge: ^1.2 || ^2.0
Requires (Dev)
- phpunit/phpunit: ~8.3
README
RoadRunner ⇆ Lumen bridge
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.