Fire and Forget kind of request

Dear coders, In Yii2, I am trying to achieve the following thing. Is this possible?

There is a form in https://example.com/user/form. Once admin fills this form and clicks on the save button, it got saved to the database.

after $model->save() method

I got 1000+ users array. In for each loop I call one URL

file_get_contents('https://example2.com/action?user_id='.$user_id);

(hosted at another place with high configured server)

On that URL I have added a code that sends an email, to write some note and use some 3rd party API for supplied user_id which takes 3-6 seconds to complete the task.

Now the issue,

[Issue]
The pointer will take the first ID from the array by loop and call the URL. After getting a response for the first ID, the pointer will call URL for the second ID. Again it waits for the response for the second ID and so on.

Is there any way we can touch the URL and not wait for a response from example2.com?

[Want]
The pointer will take the first ID from the array by loop and call the URL, then grab the second ID and call the URL, again grab the third ID and call the URL and so on.

example.com and example2.com: Both are our server. We can make necessary in both code files.

Note: I know fire and forgot request would create 1000 process in example2.com which is absolutely fine. The server is capable of handling more users.


A person’s most useful asset is not a head full of knowledge, but a heart full of love. An ear ready to listen and a hand willing to help others.

I believe you can achieve this with Curl functions.

Curl multi should do the trick.

I have not done this myself, but you will find many posts about this, such as;