2022-01-26 1262次浏览

First release of RoadRunner adapter for Yii Runner was tagged.

Despite popular belief, PHP application doesn't have to die and re-initilize every request and, thanks to RoadRunner Yii3 application could work in "initilize once" mode. There are multiple profits in using RoadRunner:

  1. Higher performance because all the framework initialization is done only once and the initialized worker may handle multiple request-responses.
  2. Tight Golang-PHP integration via Goridge RPC protocol.
  3. HTTP/2, gRPC, PSR-7 out of the box.
  4. Easy to pack into Docker since there's no need for PHP-FPM. Responses are served directly as HTTP.
  5. Out of the box logging and monitoring capabilities.
  6. Efficient queue supporting memory, AMQP, SQS, and Beanstalk.

There are two things that will be different from the application standpoint. First, instead of index.php there will be worker.php :

<?php

declare(strict_types=1);

use Yiisoft\Yii\Runner\RoadRunner\RoadRunnerApplicationRunner;

ini_set('display_errors', 'stderr');

require_once __DIR__ . '/autoload.php';

(new RoadRunnerApplicationRunner(__DIR__, $_ENV['YII_DEBUG'], $_ENV['YII_ENV']))->run();

That is quite similar to regular index.php .

Another thing is more serious. All the services should:

  1. Either have no state or use state reset.
  2. Leak no memory. See details in the draft guide article.