I'm building an integration that communicates data to several different systems via API (REST). I need to process data as quickly as possible. This is a basic layout:
- Parse and process data (probably into an array as below)
$data = array( Title => "Title", Subtitle => "Test", .....
- Submit data into service (1)
$result1 = $class1->functionservice1($data);
- Submit data into service (2)
$result2 = $class2->functionservice2($data);
- Submit data into service (3)
$result3 = $class3->functionservice3($data);
- Report completion
echo "done";
Run in a script as above I'll need to wait for each function to finish before it starts the next one (taking 3 times longer).
Is there an easy way to run each service function asynchronously but wait for all to complete before (5) reporting completion. I need to be able to extract data from each $result
and return that as one post to a 4th service.
Sorry if this is an easy question - I'm a PHP novice
Many thanks, Ben
You can also put your code in another php file and call it using this :