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
0
votes
2 answers

ReactPHP HTTP Server Running Async

I was wondering if there is a way to have a ReactPHP HTTP Server handle requests Asynchronously. I set up a very basic HTTP Server using the documentation (https://github.com/reactphp/http) HTTPServer.php
TheLovelySausage
  • 3,838
  • 15
  • 56
  • 106
0
votes
2 answers

send TCP message in loop

I am trying to send a tcp message in a script with reading from stdin in a loop. The problem is that the server only receives the connection, not the message. Everything works if I remove the loop. #!/bin/php
atmacola
  • 354
  • 2
  • 10
0
votes
1 answer

React app form with axios doesn't send data to php for DB import in 'Safari'

I am building my web app with ReactJS and I want to implement subscription page. I've got a simple form with 1 input for email, 1 select of a country and a submit button as an input as well. I used axios for the connection between js and php. On all…
0
votes
1 answer

Ratchet client event loop wait for finish

I have the following test php code: use React\EventLoop\Loop; $loop = Loop::get(); $reason = "unknown"; \Ratchet\Client\connect('wss://demo.piesocket.com/v3/channel_1?api_key=VCXCEuvhGcBDP7XhiJJUDvR1e1D3eiVjgZ9VRiaV¬ify_self', [], [],…
Veda
  • 2,025
  • 1
  • 18
  • 34
0
votes
1 answer

how to retrieve post response variable outside in reactphp

My code is as follows: require __DIR__.'/vendor/autoload.php'; use Psr\Http\Message\ResponseInterface; $loop = React\EventLoop\Factory::create(); $client = new React\Http\Browser($loop); $data = [ 'name' => [ 'first' => 'Alice', …
user1942626
  • 805
  • 1
  • 9
  • 15
0
votes
1 answer

How to make connection between two servers and have a small command console

I am reading about ReactPHP and I really love PHP doing async things, that is adding so much flexibility. I am trying to wrap my head around how to make 2 servers talk to each other while I can connect to my server (likely through an HTTP socket) to…
Maximus Light
  • 411
  • 3
  • 9
0
votes
1 answer

How to include HTML tags when making a React\Http\Message\Response (ReactPHP)

How can I write tags from HTML in React\Http\Message\Response?
Wulfo
  • 13
  • 3
0
votes
2 answers

Error code 500: Internal server error (ReactPHP)

I tried to make a server file for my ReactPHP app following this video but when I started up the server, it ran successfully, but when I made a simple http GET the response was "Error code 500: Internal server error", when in theory it should've…
Wulfo
  • 13
  • 3
0
votes
1 answer

Laravel ReactPHP Socket server need to restart on day of start

I've created the server in laravel command file & set in supervisor to run the socket server continuously to accept client msg Laravel Command file code Server.php $loop = React\EventLoop\Factory::create(); $IP = getHostByName(getHostName()); //…
Kailas
  • 3,173
  • 5
  • 42
  • 52
0
votes
1 answer

Time sleep in reponse Stream with ReactPHP

I'm playing with ReactPHP and response streaming. I've succefully created a POC to generate a response stream like this: function (int $chunks, int $sleep) use ($loop) { $stream = new ThroughStream(); $loop->addPeriodicTimer($sleep, function…
quazardous
  • 846
  • 10
  • 15
0
votes
1 answer

Sending status updates of action via Ratchet\ReactPHP

I have a secure websocket set up and working with a combination of Ratchet and ReactPHP. Part of what I want to accomplish, is to allow the user to action something which would be sent to the server, and get notification of each parts completion -…
Dan
  • 445
  • 6
  • 31
0
votes
2 answers

ReactPHP: Running server with start/stop commands

i'm creating a socket server with ReactPHP and i need it to run forever. I also have a command panel where i have to check if the process is running, and i can stop or start it (or restart it). I don't know howe to achieve this. My plan was: With…
StefanoV827
  • 269
  • 6
  • 18
0
votes
1 answer

Multiple connect using ratchet pawl

I need to listen 2 web socket URLs in real-time together. I create 2 connect to different URLs, but I see only the first message results. How can I get messages from wss://exalpme2 without close first connect? My code example …
Alex
  • 1
0
votes
1 answer

access Ratchet loop from inside the chat class

I'm trying the use the already made event loop by Ratchet. $server=IoServer::factory(new HttpServer(new WsServer(new class implements MessageComponentInterface{ public function __construct(){ // get the Ratchet Loop } public…
iTaMaR
  • 189
  • 2
  • 10
0
votes
1 answer

PHP read data from raw tcp socket and send them through WebSocket Client using 2 React Connector

Here what i'm trying to do : (Socket Server:9006) <- (Websocket Client) -> (:8080 Websocket Server) I want to read data from Socket Server, edit some stuff and then send to Websocket Server. I must be able to read data coming from Websocker Server…