What is Reactphp , is it worth using?

Asked

Viewed 1,280 times

5

I wonder what the Reactphp. I couldn’t find any material explaining what it is and what its goal is.

I’d like to know what it’s for and if it’s worth using.

  • 1

    That reply was received in connection with your reply: http://stackoverflow.com/a/24067776/1432957

1 answer

3


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

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

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

Example of use:

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: http://reactphp.org/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.