Search code examples
debuggingphpstorm

How do you display php output into phpstorm's console?


Once a debugger (xdebug) is enabled in phpstorm, you can then run your php script (without debugging) from within phpstorm.

How do you view the output of the script in phpstorms console?

I want to see php's output before it gets read by the browser - basically what you would see if you clicked "view source" in the browser.

Here is a video of a jetbrains dev. doing this (2mins:05sec into video) - he just doesnt explain HOW to configure phpstorm to do it.


Solution

  • Currently there is no such option in PhpStorm: to show web server buffer (what was sent to the browser) when debugging web page (note: this should work ONLY when debugging).

    Such option did exist for a very short period about 4 years ago (separate Script Output tab in the debugger tool window: http://youtrack.jetbrains.com/issue/WI-2826 ).. but had quite a few issues and it was removed until properly implemented.

    http://youtrack.jetbrains.com/issue/WI-18214 --> http://youtrack.jetbrains.com/issue/WI-4466


    On that video, especially around 2:05 as you have suggested, ordinary CLI script is executed (Run/Debug Configuration of PHP Script type is used) and therefore ALL such output can be easily caught (standard std output).

    With CLI scipt it's easy -- IDE is the parent here (he one who initiated script execution) so std output can easily be collected. If you execute your web page script in CLI environment, you will get your HTML in normal console output.

    With web page it works differently (the whole process): script output is first sent to the web server (parent) which in turn sends it to the browser. Since IDE does not directly participate in script execution, such interception can only happen during debugging where debugger can send a copy of collected script output back to IDE.