Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write async PHP code

I have some code that does something like this pseudocode:

Use CURL to get site1 into a variable
Use CURL to get site2 into a variable
Use CURL to get site3 into a variable
Use CURL to get site4 into a variable

Do lots of processing on each

Produce output

echo output

Currently this takes a long time occasionally.

I'd like to get the CURL bit to run in parallel so I can get things to speed up.

How do I do that?

like image 365
Rich Bradshaw Avatar asked Feb 12 '26 00:02

Rich Bradshaw


1 Answers

I think you are looking for this http://php.net/manual/en/function.curl-multi-init.php parallel cURL requests.

like image 52
Imran Naqvi Avatar answered Feb 14 '26 12:02

Imran Naqvi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!