是否可以将内容从PHP流式传输到客户端?

I want something like a REST API but because the processing server sided may take some time (5~seconds) I would like to return the content as Stream (is this possible?). I want to read the content as a byteStream in an Android App. Because I want to display the real progress (and not fake it) I would need a stream.

Is there a possibility in PHP or may an other server sided language be more suited therefor?

Regards

From what I have experienced with building web applications with PHP, what you are trying to do here takes a lot of work and often takes more effort than it pays.

An option could be the PHP function fastcgi_finish_request() if you are running PHP as FPM. This will however not allow you to track the progress of the functions you are running, but it will start a sort of background process so that the user doesn't have to wait the full 5 seconds.

An other option if you want to work with PHP might be GearMan worker, but this I don't have enough experience with to share any good information with you about. Their website http://gearman.org/

If you would like to build an android app and need data from server-side with REST API then simply use laravel as backed. Which has built in API support with authentication. And writing less code you can have it done.

Or if you know python then you can use Django. Which also easy to use as Authentication to REST API.

Or in raw php there a Function called stream get content , you can use it as you want to do in app with a API.