From cc84ef1c2495ee279ed594574189ddff2df197e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Sat, 10 Jul 2021 10:06:36 +0200 Subject: [PATCH] Simplify usage by updating to new default loop --- theme/homepage.html.twig | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/theme/homepage.html.twig b/theme/homepage.html.twig index 3abdbe5b..7faedfa3 100644 --- a/theme/homepage.html.twig +++ b/theme/homepage.html.twig @@ -41,9 +41,7 @@
{% markdown %} ```php -$loop = React\EventLoop\Factory::create(); - -$server = new React\Http\Server($loop, function (Psr\Http\Message\ServerRequestInterface $request) { +$server = new React\Http\Server(function (Psr\Http\Message\ServerRequestInterface $request) { return new React\Http\Message\Response( 200, array( @@ -53,15 +51,13 @@ $server = new React\Http\Server($loop, function (Psr\Http\Message\ServerRequestI ); }); -$socket = new React\Socket\Server(8080, $loop); +$socket = new React\Socket\Server('127.0.0.1:8080'); $server->listen($socket); -echo "Server running at http://127.0.0.1:8080\n"; - -$loop->run(); +echo "Server running at http://127.0.0.1:8080" . PHP_EOL; ``` {% endmarkdown %} -

This simple web server written in ReactPHP responds with "Hello World" for every request.

+

This simple web server written in ReactPHP responds with "Hello World!" for every request.