slimphp / slimphp/Slim

Unbuffered streaming output

Open
#3,323 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
12.3k
Forks
2k
Avg merge
3d 2h
Merged PRs (30d)
6

Description

Hi, I am writing directly to php://output in my action because I do not want to buffer (large) output in memory or on disk. However, Slim quietly elects not to send headers in this case, because ResponseEmitter::emit notices headers_sent now returns true. How can I still send custom headers whilst writing output directly to PHP's output stream?

Note: Symfony supports this with StreamedResponse.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at ResponseEmitter::emit and inspect how headers_sent affects emission when the action writes directly to php://output. Compare the requested behavior with Symfony's StreamedResponse. Done means custom response headers can still be sent for unbuffered streaming output without buffering it in memory or on disk.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.