octane: Response doesn't support stream-based output
- Octane Version: 0.1.0
- Laravel Version: 8.36.1
- PHP Version: 8.0.3
- Database Driver & Version:
Description:
Most of PHP’s output usages like echo, var_dump output its content to buffer. In Swoole’s case the result will print on console instead of web.
It seems this partial code in SwooleClient.php refers from here https://github.com/laravel/octane/blob/08537a7ed6d2c463f76278081ac7af9a6dd1dead/src/Swoole/SwooleClient.php#L153-L178 because the output property doesn’t exist in symfony’s response object. The output property is set from here in swooletw/laravel-swoole.
Symfony\Component\HttpFoundation\StreamedResponse doesn’t support getContent and setContent for setting output content, so I fetch buffer output and set the result to response’s output property manually.
If Octane is going to support stream output, it needs to use ob_ functions to catch stream content as well.
Many thanks to the official team for integrating Swoole into Laravel!
Steps To Reproduce:
echo 'hello world';
var_dump('Swoole is awesome');
response()->streamDownload(function () {
echo file_get_contents("https://github.com/laravel/laravel/blob/8.x/README.md");
}, 'laravel-readme.md');
});
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 16 (10 by maintainers)
Had to look into it - https://github.com/php/php-src/commit/888f376e4cc2c87b0e0c4214e3a5af52f4160b28 Another one of those 21 year old features I’ve never noticed ; )
Thanks @barryvdh !