Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP request "in background"

Is there a way to make PHP request where user doesn't have to wait for response? Some sort of "php request in background"?

For example, if application needs to send 100 emails because the user had submitted something, I don't want to show "sending... please wait" for this user, but I want some other script to do the job independent from that user...

like image 257
domagojk Avatar asked Dec 22 '25 22:12

domagojk


1 Answers

Options:

  1. Stick in a db (or a file) and use a cron to poll it (easiest as you probably already use a db).
  2. Use something like RabbitMQ or ØMQ (my favourite)
  3. Spawn a separate process to do it using fork/exec (would not recommend that).
  4. As others have suggested - fake it by using an Ajax request. Viable - but I find it ugly.
like image 85
Emil Ivanov Avatar answered Dec 24 '25 12:12

Emil Ivanov



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!