yii2-extensions/road-runner

Yii2 Road Runner runtime.

dev-main / 1.0.x-dev 2025-08-03 18:44 UTC

This package is auto-updated.

Last update: 2025-08-03 18:44:25 UTC


README

Yii Framework

Extension for Road Runner


PHP Version Yii2 2.0.53 Yii2 22.0 PHPUnit Mutation Testing Static Analysis

A high-performance RoadRunner integration for Yii2 applications that provides seamless PSR-7 request handling with automatic memory management and error reporting.

Features

  • 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.

Quick start

Installation

composer require yii2-extensions/road-runner

Basic Usage

Create your RoadRunner entry point (public/index.php):

<?php

declare(strict_types=1);

use yii2\extensions\psrbridge\http\StatelessApplication;
use yii2\extensions\roadrunner\RoadRunner;

defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';

$config = require dirname(__DIR__) . '/config/web/app.php';

$runner = new RoadRunner(new StatelessApplication($config));

$runner->run();

RoadRunner configuration

Create .rr.yaml in your project root.

version: '3'
server:
    command: "php ./public/index.php"

rpc:
    listen: tcp://127.0.0.1:6001

http:
    address: :8080
    pool:
        num_workers: 4
    timeout: 30s
    read_timeout: 30s
    write_timeout: 30s
    middleware: ["static", "headers"]
    static:
        dir:   "./public"
        forbid: [".php", ".htaccess"]
    headers:
        response:
            "Cache-Control": "no-cache"

logs:
    mode: development
    level: debug

Start the server

# install RoadRunner binary
vendor/bin/rr get

# start the server
./rr serve

Your application will be available at http://localhost:8080.

Documentation

For detailed configuration options and advanced usage.

Quality code

Latest Stable Version Total Downloads codecov phpstan-level StyleCI

Our social networks

X

License

License