I needed parallel processing in PHP, but PHP doesn’t support it without installing extensions, so I’m using multi_curl to achieve this.
main.php – Builds an array of urls, which are all process.php with different $_GET parameters. Then executes them all using multi_curl.
process.php – The processing logic for each thread.
I’d just like to know if this is a viable way of doing things. Is this retarded? Does it cause a lot of overhead? Is there a more sensible way of doing this? Thanks.
https://github.com/krakjoe/pthreads
Threading for PHP …
Enjoy …
To install in unix, you’ll need a Thread Safe version of PHP. Most distros do not package this version so you’ll have to build it yourself.
A quick description of how to do so would be:
I’d start with that, to build an isolated copy –prefix with a private location, like –prefix=/home/mydir, or some distros have a /usr/src/debug which is a good place for that sort of thing. You’ll obviously want to add –with-mysql and the like, but how you do that depends on your system ( hint, you can use php -i | grep configure > factory.config to save your current php installations configure line and base your custom build of that knowing that any libaries it complains aren’t available are an apt-get|yum install away ).