I have a RESTful API built with PHP. In POST request saving to DB is triggered. The problem is that now I have to support long running tasks. For example a user triggers POST request that is going to take a few minutes to be processed and having to wait is not a good option.
From what I've learnt from now: One of the best practices is something like this - user sends POST request with data, API returns status 202 Accepted and sends a location header with an URL where user will obtain the result (once it's ready).
But how can I achieve this if there is no asynchronous/multithreading stuff in PHP? My endpoint will have to return status 202 and trigger a process (start writing to DB).
I don't want to let the user waiting for his POST request until the result is obtained ( so it needs to happen like I've described ).
Anyone has any idea?