What is ReactPHP, what good is it worth to use?

5

I'd like to know what ReactPHP . I have not found any material explaining what it is and what its purpose is.

I'd like to know what it's all about and worth using.

    
asked by anonymous 10.03.2017 / 12:14

1 answer

3

REactPHP is a low-level library for event-oriented programming in PHP.

At its core is an event loop, which provides low-level utilities such as: abstraction of flows, asynchronous DNS resolution, network client / server, http client / server, process interaction.

Third-party libraries can use these components to create asynchronous network clients / servers and more.

Example usage:

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();

See also: link

    
14.05.2017 / 01:34