2 ms·
If you want to use libevent/libev without coding the glue yourself, you can use React PHP (http://reactphp.org/ http://reactphp.org/), which supports timers, we
by tmzt 13y ago
If you want to use libevent/libev without coding the glue yourself, you can use React PHP (http://reactphp.org/ http://reactphp.org/), which supports timers, websocket/WAMP, ZeroMQ, HTTP (but not SSL), DNS, Redis (Predis async), and plain sockets.
I'm using it for a project I'm working on because PHP has the only supported cpanel client library, and I don't want to maintain my own bindings for cpanel. I've found that React works quite well for processing queues in PHP and notifying the client via websocket when events occur.
I did introduce a Play/Akka scheduling daemon instead of hand rolling that in React, which simplifies the PHP worker greatly as it only needs to process jobs submitted over ZMQ, not read the database and update an internal list of jobs.
I would love to try porting this application to HHVM when there is support for a libev/libevent/libuv extension that is compatible with React.
I was not aware of the async database library in PHP, though it doesn't seem to be integrated with the React main loop implementation and might be some work to get it working. Are you aware of the difference between Mysqli and Mysqlnd and do you know when I should use either on of them. (I use PDO for database access and prefer the OO api it provides.)
- yareally 13y agoHmm, I've heard of React, but have not had a chance to look at it much or use it yet. Looks like it would be better than any of the other alternatives out there though for PHP with a similar feature set. Thanks for the recommendation. MySQLnd uses the same API as MySQLi, so the only differences are deciding which to use within php.ini file and ability to use the asynchronous methods in for the MySQLi API in PHP. When MySQLnd originally came out, there was no support for SSL connections with it, but that's been fixed since PHP 5.4 I believe. Won't be able to use PDO though if wanting to use the async stuff (unless they have added that). Could probably write a small adapter to wrap one or the other though. MySQLi API design is kind of quirky compared to PDO API, so I generally write a small helper class to make life easier for dealing with prepared statements and binding variables to them.