How do you display php output in phpstorm console?

Once the debugger (xdebug) is enabled in phpstorm, you can run the php script (without debugging) from phpstorm.

How do you view script output in phpstorms console?

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

Here is a video from the jetbrains developer. doing this (2mins: 05sec in the video) - it just does not explain HOW to configure phpstorm for this.

+7
source share
2 answers

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

This option existed for a very short period about 4 years ago (a separate Script Output tab in the debugger tool window: http://youtrack.jetbrains.com/issue/WI-2826 ) .. but there were quite a few problems and it was removed until it is properly executed.

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


In this video, especially around 2:05, as you suggested, the usual CLI script is executed (the Run / Debug Configuration PHP ), and therefore ALL such weekends can (standard output std).

With the scipt CLI, this is easy - the IDE is the parent here (it initiated the execution of the script), so std output can be easily compiled. If you execute your webpage script in the CLI, you will get your HTML in the regular console release.

It works differently with a web page (the whole process): the script output is first sent to the web server (parent), which, in turn, sends it to the browser. Since the IDE is not directly involved in the execution of the script, such an interception can only occur during debugging, when the debugger can send a copy of the assembled script file back to the IDE.

+6
source

Most web frameworks buffer output before sending the results to a web server. To view the contents of this buffer, first insert a breakpoint at the desired location, then when it is reached, go to the Debug => Console tab and execute ob_get_contents() . PHP output buffering supports nested levels, so keep this in mind when choosing a breakpoint. Obviously, if the CMS / framework does not use output buffering, this method does not apply.

0
source

Source: https://habr.com/ru/post/972374/


All Articles