PHP Classes

File: example/server.php

Recommend this page to a friend!
  Classes of Ahmad Mustapha   ReactPHP HTTP Server Response   example/server.php   Download  
File: example/server.php
Role: Example script
Content type: text/plain
Description: Example script
Class: ReactPHP HTTP Server Response
Generate HTTP server responses using middleware
Author: By
Last change:
Date: 2 years ago
Size: 557 bytes
 

Contents

Class file image Download
<?php

use React\EventLoop\Factory;
use
React\Socket\Server;
use
Reaponse\Http\Middleware;

require
'vendor/autoload.php';

$loop = Factory::create();
$uri = '0.0.0.0:9200';

$myServer = new \Test\ServerHandler();
$myCounter = new \Test\CounterHandler();

$httpServer = new \React\Http\Server($loop, new Middleware($myCounter, $myServer));
$socketServer = new Server($uri, $loop);

$httpServer->listen($socketServer);
$httpServer->on('error', function (Throwable $throwable){
    echo
$throwable;
});

echo
"Server started at http://{$uri}\n";
$loop->run();