Skip to content

Instantly share code, notes, and snippets.

@ngyuki
Created July 22, 2014 06:35
Show Gist options
  • Save ngyuki/e7216035012ab66a07a7 to your computer and use it in GitHub Desktop.
Save ngyuki/e7216035012ab66a07a7 to your computer and use it in GitHub Desktop.
<?php
// composer require react/react:\*
require __DIR__ . '/vendor/autoload.php';
use React\EventLoop\Factory;
use React\Socket\Server as SocketServer;
use React\Http\Server as HttpServer;
use React\Http\Request;
use React\Http\Response;
$loop = Factory::create();
$socket = new SocketServer($loop);
$http = new HttpServer($socket);
$http->on('request', function (Request $request, Response $response) {
$response->writeHead();
$response->end('hello');
});
$socket->listen(8888, '0.0.0.0');
$loop->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment