Created
August 19, 2013 00:47
-
-
Save goofmint/6264921 to your computer and use it in GitHub Desktop.
ReactPHP demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
$app = function ($request, $response) { | |
$response->writeHead(200, array('Content-Type' => 'text/plain')); | |
$response->end("Hello World\n"); | |
}; | |
$loop = React\EventLoop\Factory::create(); | |
$socket = new React\Socket\Server($loop); | |
$http = new React\Http\Server($socket, $loop); | |
$http->on('request', $app); | |
echo "Server running at http://127.0.0.1:1337\n"; | |
$socket->listen(1337); | |
$loop->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment