Skip to content

Commit cd14db7

Browse files
authored
Added README for ReactPHP (#18)
1 parent 2ab6607 commit cd14db7

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
```

0 commit comments

Comments
 (0)