Questions tagged [reactphp]

React is a low-level library for event-driven programming in PHP.

Event-driven, non-blocking I/O with PHP. http://reactphp.org/ React is a low-level library for event-driven programming in PHP. At its core is an event loop, on top of which it provides low-level utilities, such as: Streams abstraction, async dns resolver, network client/server, http client/server, interaction with processes. Third-party libraries can use these components to create async network clients/servers and more.

The event loop is based on the reactor pattern (hence the name) and strongly inspired by libraries such as EventMachine (Ruby), Twisted (Python) and Node.js (V8).

172 questions
38
votes
1 answer

Is ReactPHP truly asynchronous?

I've been doing some tests on ReactPHP because it looks pretty awesome. I've tested it with the following react/socket code, for a simple socket server. $loop = React\EventLoop\Factory::create(); $socket = new…
Divi
  • 800
  • 1
  • 7
  • 16
18
votes
2 answers

Ratchet PHP WAMP - React / ZeroMQ - Specific user broadcast

Note: This is not the same as this question which utilises MessageComponentInterface. I am using WampServerInterface instead, so this question pertains to that part specifically. I need an answer with code examples and an explanation, as I can see…
Jimbo
  • 25,790
  • 15
  • 86
  • 131
13
votes
1 answer

Reactphp process status statistic (idle, worked, etc)

I starting using http://reactphp.org/ for handle HTTP request. I run multiple react workers that run on different ports and then use Nginx as load balancing to handle requests. Like this upstream backend { server 127.0.0.1:13300; server…
10
votes
2 answers

Guzzle vs ReactPHP vs Amphp for parallel requests

What's the difference between: GuzzleHttp ReactPHP Amphp How they differ and what would be typical use case to use with?
lubosdz
  • 4,210
  • 2
  • 29
  • 43
8
votes
1 answer

Why websockets stop broadcasting after some time? ( implementation uses ReactPHP, Ratchet & ZeroMQ )

I have a small websocket server, running on top of a set of libraries: ReactPHP, Ratchet and ZeroMQ, using a php-zmq wrapper. The code is basically the same as in the tutorials. The eventloop starts correctly, users are able to connect to the…
Finwe
  • 6,372
  • 2
  • 29
  • 44
7
votes
1 answer

Docker running ReactPHP http server script - not exposing the port

I am experimenting with building lightweight api server, that needs to handle many req/sec, using the following tech: 7.1-cli-alpine (docker image) - small memory/disk footprint, no need for web server ReactPHP - low-level library for event-driven…
Latheesan
  • 23,247
  • 32
  • 107
  • 201
7
votes
2 answers

I need to implement a wait timer INSIDE of a PHP React websocket event loop (perhaps multithreading?)

I have a websocket application that I am building a game on, built on Ratchet which uses the React event loop. At the start of this script, I have already figured out how to implement a periodictimer, to send a pulse to the game every second, and…
Lynne
  • 150
  • 12
7
votes
1 answer

Asynchronous Socket Client Buffer Size

I have to connect a remote server with asynchronous socket connection and retrieve data. I can connect but there is a problem. Packages are sending by pieces. I have two options; I can set a buffer and get whole package in one piece or combine…
Deniz B.
  • 2,532
  • 1
  • 18
  • 35
7
votes
1 answer

How React PHP handles async non-blocking I/O?

How React PHP handles async non-blocking I/O ? Nodejs uses its event queue which handles I/O on different threads. It uses libuv for this. As in PHP there isn't something like that, How React handles non-blocking I/O process on a single thread ?
Reza Shadman
  • 617
  • 6
  • 15
6
votes
1 answer

Gracefully close ReactPhp app

The question is very related to Consume only N messages from RabbitMQ with react\stomp, ack them separately and then exit, but a bit more general. For example, I have a slow I/O operation: $port = 4000; $loop =…
Alex Blex
  • 34,704
  • 7
  • 48
  • 75
6
votes
1 answer

React PHP with Laravel 4

I'm using Laravel 4 and as I was going through React PHP , wandering if there is any way to use React PHP with Laravel. Is there any example to start with React PHP with Laravel ? or any suggestion to use it with Laravel ?
Chinmoy
  • 318
  • 5
  • 15
5
votes
1 answer

waiting for all promises to finish in react PHP

I have an array of promises. I want to proceed only after all of the promises gave me a response no matter if they were resolved or reject. I thought that all() function can handle it, but it looks like it works only when all of the promises in the…
Ohad Koren
  • 121
  • 2
  • 5
5
votes
1 answer

Ratchet PHP and long running tasks

I am using ratchet php. I am starting it like this: $loop = \React\EventLoop\Factory::create(); $webSock = new \React\Socket\Server($loop); $webSock->listen($this->port, $this->host); $webServer = new \Ratchet\Server\IoServer( new…
harveyslash
  • 5,906
  • 12
  • 58
  • 111
5
votes
1 answer

Run function in PHP CLI script after period of inactivity

I used Symfony2 with the RabbitMqBundle to create a worker that sends documents to ElasticSearch. Indexing documents at a one-by-one rate is much slower than using the ElasticSearch bulk API. Therefore I created a buffer that flushes the documents…
Sander Toonen
  • 3,463
  • 35
  • 54
5
votes
2 answers

Alternative web server for PHP: React or PHP's embedded server?

I always used Apache for my PHP projects. But now, I want to leave it, to start using one of the following options: React or PHP's built-in web server Which has more performance? In definitely, what is the best? Which is your recommendation?
user2359967
1
2 3
11 12