Details
When a user first logs into my app I need to import all of their store’s products from an API, this can be anywhere from 10 products to 11,000. So I’m thinking I need to to inform the user that we’ll import their products and email them when we’re finished.
Questions
What would be the best way to go about importing this data without requiring the user to stay on the page?
Should I go down the pcntl_fork route?
Would system style background tasks be better?
I think the “standard” way to do this in PHP would be to run a cron every five minutes or so that checks a queue of pending imports.
So your user logs in, part of the log in process is to add them to your “pending_import” table (or however you choose to store the import queue). Then the next time the cron fires it will take care of the current contents of your queue.