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:
- Higher performance because all the framework initialization is done only once and the initialized worker may handle multiple request-responses.
- Tight Golang-PHP integration via Goridge RPC protocol.
- HTTP/2, gRPC, PSR-7 out of the box.
- Easy to pack into Docker since there's no need for PHP-FPM. Responses are served directly as HTTP.
- Out of the box logging and monitoring capabilities.
- 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:
- Either have no state or use state reset.
- Leak no memory.