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
2
votes
1 answer

Deploy ReactPHP on PHP host

I use the example for the chat server in ReactPHP. My server listens on port 8080 $socket = new React\Socket\Server(8080, $loop); $server->listen($socket); in my local PC. The written code is working correctly but when upload files into my Linux…
hamed hossani
  • 986
  • 2
  • 14
  • 33
2
votes
1 answer

How do I "extract" the data from a ReactPHP\Promise\Promise?

Disclaimer: This is my first time working with ReactPHP and "php promises", so the solution might just be staring me in the face I'm currently working on a little project where I need to create a Slack bot. I decided to use the Botman package and…
rugaard
  • 81
  • 1
  • 9
2
votes
1 answer

How to send multiple requests at once ReactPHP?

I am using guzzle to send some requests: $response = $this->client->request(new SomeObject()); using the class below ... public function request(Request $request) { return $this->requestAsync($request)->wait(); } // Here I'm using Guzzle…
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
2
votes
1 answer

How to reconnect a client automatically on reactphp?

I'm using reactphp to create a client for an api server. But i have a problem, when my connection close, whatever the reason, i can't reconnect automatically. It doesn't work: $this->loop = \React\EventLoop\Factory::create(); $host =…
Ivan
  • 91
  • 7
2
votes
1 answer

ReactPHP - Working with Laravel and Timers

So here is a very interesting problem I am having. I am dead set on trying to figure out how to integrate a websocket client into Laravel 5.5 to allow communication over a websocket between my application and a Discord Gateway. I spooled up a new…
DevOverlord
  • 456
  • 3
  • 19
2
votes
0 answers

ReactPHP make a synchronous call to a socket

I am rather new to ReactPHP but I am trying to achieve something that at first seems a bit tricky. I have set up a php script, which serves as a server, what is listening for connections through a socket. When a connection is estabilished, it is…
Adam Baranyai
  • 3,635
  • 3
  • 29
  • 68
2
votes
1 answer

Using Monolog and ReactPHP

I'm trying to build my Symfony application on top of ReactPHP engine, and everything goes fine, but the logs. I have my application configured with a regular file log under devel environment, and a simple syslog log with level=error under…
mmoreram
  • 687
  • 5
  • 13
2
votes
2 answers

Detecting if React PHP client cannot connect to server

How can it be detected that a React PHP client cannot connect with a server? I was hoping for the fictional else() method that I showed at the bottom. Do I just need to wait a reasonable amount of time, and if no on data event occurs, it isn't…
user1032531
  • 24,767
  • 68
  • 217
  • 387
2
votes
2 answers

Using reactive PHP in a blocking application

I'm currently working on a PHP application that will be using some websocket connections to talk to another service. To talk to this websocket service, we are using Ratchet - which is a PHP library based on react PHP. This piece of code needs to…
Rob
  • 4,927
  • 4
  • 26
  • 41
2
votes
1 answer

How to retrieve newly created entity by asynchronous command (CQRS) in same php process?

I am implementing PHP application with CQRS. Let's say I have CreateOrderCommand and when I do $command = new CreateOrderCommand(/** some data**/); $this->commandBus->handle($command); CommandBus now just pass command to proper…
Tom
  • 189
  • 1
  • 12
2
votes
1 answer

How to keep state in reactPHP server?

ReachPHP server. Code for counting the number of requests: $counter = 0; $app = function ($request, $response) use ($counter){ $response->writeHead(200, array('Content-Type' => 'text/plain')); $response->end($counter); …
Grigory Ilizirov
  • 1,030
  • 1
  • 8
  • 26
2
votes
1 answer

Connecting to react server from another machine

Following the instructions at http://reactphp.org/, I created a server: writeHead(200, array('Content-Type' => 'text/plain')); $response->end("Hello…
user1032531
  • 24,767
  • 68
  • 217
  • 387
2
votes
0 answers

Ratchet onopen client not fire

I am trying to implement Ratchet Socket Hello word on my local machine every things works perfectly but on vps centos server when i run server service with ssh Command : php chat-server.php it start Listening on port correctly(i can see on linux…
Sam Rad
  • 451
  • 2
  • 5
  • 13
2
votes
1 answer

Write LogFile with date on running service

I've created a service with reactphp which runs and does some stuff. It is started as a daemon so all output should be logged in a file. This log file should be named 'foo-log-file-$(date "+F")'. I want to have a single log file for each day.…
alabama
  • 413
  • 7
  • 19
2
votes
1 answer

Running code parallel with ReactPhp

Problem: I need to clone/download several git repositories, unfortunately doing it sequentially takes ages. I got idea to use ReactPhp event loop and do it parallelly. Despite of many attempts I am not able to get it running parallelly. Maybe I…
mrok
  • 2,680
  • 3
  • 27
  • 46
1 2
3
11 12