4 ms·
There has been threading in PHP via the pcntl_ functions for a long while - since PHP4. You have to have some pretty exotic needs to want to use them, but thre
by madaxe_again 8y ago
There has been threading in PHP via the pcntl_ functions for a long while - since PHP4.
You have to have some pretty exotic needs to want to use them, but threading does exist, and I’ve built a multithreaded php app using it.
- gnarcoregrizz 8y agoThe needs aren't very exotic. You can use them any time you need to do multiprocessing, a common example is building a daemon to process a queue in parallel with multiple workers. Also, the pcntl functions don't provide multithreading primitives, only multiprocessing (fork) Edit, looks like there is also a pthreads extension
- codedokode 8y agoBetter solution might be to run several daemon processes in parallel.
- Shish2k 8y ago> The needs aren't very exotic [...] a common example is building a daemon While "writing a daemon" is pretty common, I've never seen a daemon written in PHP (I'm sure they exist, I've just never seen one), so I would call that an exotic use-case :P
- aequitas 8y agoI had to maintain one, would not recommend it as a general pattern. Most of the problems might as easy have to do with the original author and his experience in writing such an application (and hence choice of PHP for this task). But this post also springs to mind: https://software-gunslinger.tumblr.com/post/47131406821/php-is-meant-to-die https://software-gunslinger.tumblr.com/post/47131406821/php-...