A high-performance RoadRunner integration for Yii2 applications that provides seamless PSR-7 request handling with automatic memory management and error reporting.
- ✅ Automatic Memory Management: Smart cleanup with configurable memory limits.
- ✅ Error Handling: Comprehensive error reporting to RoadRunner worker.
- ✅ Graceful Shutdown: Automatic worker restart when memory usage is high.
- ✅ High Performance: Utilize RoadRunner's blazing-fast HTTP server for your Yii2 applications.
- ✅ Production Ready: Battle-tested error handling and worker lifecycle management.
- ✅ PSR-7 Compatible: Full PSR-7 request/response handling through the PSR bridge.
- ✅ Stateless Design: Memory-efficient stateless application lifecycle.
- ✅ Zero Configuration: Works out of the box with minimal setup.
composer require yii2-extensions/road-runner:^0.1.0@dev
Create your RoadRunner entry point (web/index.php
)
<?php
declare(strict_types=1);
use yii2\extensions\psrbridge\http\StatelessApplication;
use yii2\extensions\roadrunner\RoadRunner;
// production default (change to 'true' for development)
defined('YII_DEBUG') or define('YII_DEBUG', false);
// production default (change to 'dev' for development)
defined('YII_ENV') or define('YII_ENV', 'prod');
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
$config = require dirname(__DIR__) . '/config/web.php';
$runner = new RoadRunner(new StatelessApplication($config));
$runner->run();
Create .rr.yaml
in your project root
version: '3'
rpc:
listen: 'tcp://127.0.0.1:6001'
server:
command: 'php web/index.php'
relay: pipes
http:
address: '0.0.0.0:8080'
headers:
response:
"Cache-Control": "no-cache"
middleware:
- static # serve files first
- gzip # compress dynamic output
static:
dir: web
forbid:
- .php
- .htaccess
pool:
num_workers: 1
supervisor:
max_worker_memory: 100
jobs:
pool:
num_workers: 2
max_worker_memory: 100
consume: { }
kv:
local:
driver: memory
config:
interval: 60
metrics:
address: '127.0.0.1:2112'
# install RoadRunner binary
vendor/bin/rr get
# start the server
./rr serve
Your application will be available at http://localhost:8080
For detailed configuration options and advanced usage.