Event-driven, non-blocking I/O with PHP.
The recommended way to install react is through composer.
{
"require": {
"react/react": "dev-master"
}
}
- Usable with a bare minimum of PHP extensions, add more extensions to get better performance.
- Provide a standalone event-loop component that can be re-used by other libraries.
- Decouple parts so they can be replaced by alternate implementations.
React is non-blocking by default. Use workers for blocking I/O.
Most classes extend événement, allowing you to bind to events.
Here is an example of a simple HTTP server listening on port 1337:
<?php
$i = 1;
$app = new React\Espresso\Application();
$app->get('/favicon.ico', function ($request, $response) {
$response->writeHead(204);
$response->end();
});
$app->get('/', function ($request, $response) use (&$i) {
$i++;
$text = "This is request number $i.\n";
$headers = array('Content-Type' => 'text/plain');
$response->writeHead(200, $headers);
$response->end($text);
});
$stack = new React\Espresso\Stack($app);
$stack->listen(1337);
Check out #reactphp on irc.freenode.net. Also follow @reactphp on twitter.
To run the test suite, you need PHPUnit.
$ phpunit
MIT, see LICENSE.