File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ # ReactPHP Runtime
2+
3+ A runtime for [ ReactPHP] ( https://reactphp.org/ )
4+
5+ ## Installation
6+
7+ ```
8+ composer require runtime/react
9+ ```
10+
11+ ## Usage
12+
13+ Define the environment variable ` APP_RUNTIME ` for your application.
14+
15+ ```
16+ APP_RUNTIME=Runtime\React\Runtime
17+ ```
18+
19+ ### PSR-15
20+
21+ ``` php
22+ // public/index.php
23+
24+ use Psr\Http\Server\RequestHandlerInterface;
25+ use Psr\Http\Message\ServerRequestInterface;
26+ use Psr\Http\Message\ResponseInterface;
27+ use Nyholm\Psr7;
28+
29+ require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
30+
31+ class Application implements RequestHandlerInterface {
32+ // ...
33+ public function handle(ServerRequestInterface $request): ResponseInterface
34+ {
35+ return new Psr7\Response(200, [], 'PSR-15');
36+ }
37+ }
38+
39+ return function (array $context) {
40+ return new Application($context['APP_ENV'] ?? 'dev');
41+ };
42+ ```
You can’t perform that action at this time.
0 commit comments