3 ms·
There is a project called ReactPHP [1] which provides a nodejs-like event loop and async execution. However, I think the power of PHP is that it is not designe
by stabbles 10y ago
There is a project called ReactPHP [1] which provides a nodejs-like event loop and async execution.
However, I think the power of PHP is that it is not designed to be its own server, to run forever in the background and handle all kinds of complex async flow. Execution stops when a request is done: no memory and data leaks between requests and easy to reason about.
In practice you don't really need async, except for stuff like sending emails and heavy IO. Laravel simply handles this by pushing jobs on a message queue and handling it via a worker process, but you can use any microservice of course (in particular a simple node app).
[1] http://reactphp.org/ http://reactphp.org/
- robryan 10y agoI am by no means an expert on the subject but use Ratchet (http://socketo.me/ http://socketo.me/) with proxying through nginx for my limited websocket needs. Works well.
- em1t 10y agoI've only tried Ratchet in a sandbox and not in any production project. And as far as that, it worked well. I've done some minor stuff involving ReactPHP (which Ratchet uses for some parts) in the early days of the project, but same here - nothing that was deployed to production. I'm no expert either, but I just leave a note regarding Pushpin (http://pushpin.org/ http://pushpin.org/) here as an option to have a websocket server together with PHP. It's not a PHP project, but a good tool to have in the toolbox :)