flow-development-collection
flow-development-collection copied to clipboard
BUG: Make it possible to var_dump without interfering with the header.
I often do some var_dump 's here and there, and sometimes Flow doesn't like them because they interfere with the header (When one misses the die()).
Its strange because when you for example put a var_dump/echo here: Neos FusionView, then only that many characters of the echo will be displayed as how many where rendered in Fusion?
At first, I didn't know about the die() pattern - and the current header interference is kind of buggy, unpredictable and strange - to me, not a good dev experience for beginners.
The function RequestHandler::sendResponse is the point where Flow sets the header() and calling header() while there is content in the output buffer behaves strange, as it seems.
So I want to propose:
- that the method sendResponse will make a check in dev context? If there is content in the buffer, else it sets the header. (Of course it could also send a warning, that you're operating now without headers)
if (ob_get_length() === 0) {
set headers and co ....
}
- get the content into a variable with
ob_get_clean()and prepend it to the actual output after the headers are set. Should work? - make a check if the buffer has content and throw an exception, that you should not
var_dumpwithoutdie().
At last: sure, dumping stuff at random locations is certainly not a feature, but to me, it's about the dev experience.
Or maybe this way? https://github.com/avency/Avency.Neos.VarDump
A var_dump eel helper would then also work without die()
have a look at the approach in https://github.com/PackageFactory/PackageFactory.Fusion.Debug
my above ideas dont work -> without ob_start we cant get its contents.
we would need to use if headers_sent() but thats generally dangerous as we would allow it to silently fail setting the headers.
actually i currently cannot reproduce the above behavior with php 8.0 and neos 8.2:
Its strange because when you for example put a var_dump/echo here: Neos FusionView, then only that many characters of the echo will be displayed as how many where rendered in Fusion?
so maybe that fixed itself over the time?
but the floating var_dump still doesnt work with the exception rendering:

Or maybe this way? https://github.com/avency/Avency.Neos.VarDump
Nice! A solid solution for this issue IMO