My immediate answer should be: you cannot.
PHP does not have the streaming capabilities that can be used in userland.
Now, if you really want to do this, there are several ways around this:
- Use the exec functions to start another process in the background and control it through a database / file system or something else.
- Use the fork function to start another process and control it through a database / file system or something else.
The elimination of these two approaches is that you can make it asynchronous, but if you want a callback, then it will be very difficult and not at all trivial. Well, it wonโt even be a callback, since you wonโt be able to wait for it in a script, which makes an asynchronous call. This means that you can only have some kind of monitoring scheme. I would suggest AJAX.
source share