A runtime for ReactPHP.
If you are new to the Symfony Runtime component, read more in the main readme.
composer require runtime/react
Define the environment variable APP_RUNTIME
for your application.
APP_RUNTIME=Runtime\React\Runtime
// public/index.php
use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Nyholm\Psr7;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
class Application implements RequestHandlerInterface {
// ...
public function handle(ServerRequestInterface $request): ResponseInterface
{
return new Psr7\Response(200, [], 'PSR-15');
}
}
return function (array $context) {
return new Application($context['APP_ENV'] ?? 'dev');
};
Option | Description | Default |
---|---|---|
host |
The host where the server should bind to (precedes REACT_HOST environment variable) |
127.0.0.1 |
port |
The port where the server should be listening (precedes REACT_PORT environment variable) |
8080 |