thephpleague/booboo

Wrong HTTP status code on error

Closed this issue · 1 comments

The HTTP status code is only set when using an error page:
https://github.com/thephpleague/booboo/blob/master/src/Runner.php#L135

Is this the desired behavior?

Yes. In development, you may have a notice or a warning show up. If that happens, execution isn't halted (unless you have the turn errors into exceptions option enabled). It's possible that you could then emit the warning during page rendering after the headers have been sent and trigger ANOTHER error by trying to send the error header.

E.g.:

echo "hello";

echo $name; // Will produce a Undefined variable: name notice

Because output starts on the first line, the header sent by BooBoo on the third line would be ANOTHER error, making debugging harder.

When in production and using an error page, the goal is to capture ALL output, and dump any previously rendered content before it hits the wire. This lets us modify the headers to suit our needs.