Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP response streaming #572

Open
puzzledpolymath opened this issue Jan 29, 2025 · 2 comments
Open

PHP response streaming #572

puzzledpolymath opened this issue Jan 29, 2025 · 2 comments

Comments

@puzzledpolymath
Copy link

I’m hoping someone can clarify whether streaming responses using PHP is possible, and perhaps some implementation details?

@bnusunny
Copy link
Contributor

It should work. Just stream the response from PHP. I'm not so familar with PHP, but I could try to write a simple example.

@puzzledpolymath
Copy link
Author

puzzledpolymath commented Jan 30, 2025

I’m coming from PHP Bref and it wasn’t clear to me whether HTTP headers (chunked) needed to be declared, or whether it is as simple as:

set_time_limit(0);
ob_implicit_flush(1);
ob_end_flush();

sleep(1);
echo json_encode(['data' => 'test 1']);

sleep(2);
echo json_encode(['data' => 'test 2']);

sleep(1);
echo json_encode(['data' => 'test 3']);
die(1);

I’ll try and do some testing on my own when I get the time. If you’re able to put together a working example, myself and other PHP developers will surely appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants