index.php is parsed by Apache. It needs to pass some data to another PHP instance which happens to be a reactphp loop. How can this be best accomplished? Both scripts are run on the same machine.
<?php
//index.php
$status=sendDataToOtherInstance('hello'); //blocking function which returns true/false
.
<?php
//reactphp loop
$foo->on('connection', function ($data){
echo($data);
return $data==='hello';
});
Few options:
HTTP between the 2 processes
Like you say this is a bit messy, not too bad, it will be quick, but a little messy.
Unix socket file
Only problem is
reactphp
doesn't work with unix sockets at the minute.More info: https://github.com/reactphp/socket/pull/17
TCP Socket
This should work. But just as clunky as the 1st option.
To be honest it sounds like your getting to the limits of php.
Node.js
I'm not sure if you've ever used it, but
node.js
was made for this sort of task. And allows lots of functionality php does not.https://nodejs.org/en/