Get the most out of PHP debugging with PhpStorm and Xdebug.
PhpStorm’s debugging GUI provides versatile breakpoint tooling. Use conditional breakpoints to zero in on hit conditions, such as specific items in the loop. Need to catch an exception when it is thrown? Use exception breakpoints, which are applicable throughout the project’s entire codebase.
Breakpoints and their settings don’t affect your source files, but can be saved with your PhpStorm project and reused across debugging sessions.
If you want to debug control flow and examine data structures at every line of executed code, you don’t need to put breakpoints everywhere. Instead, you can step through your code and inspect the current frame stack and variables at each step in the Debug tool window.
You can even step into a specific function for more granular line-by-line debugging.
PhpStorm’s interactive Debug tool window lets you play around with the current program state – alter variables, call or define PHP functions, or evaluate arbitrary expressions – without making any changes in your source code.
When a program is suspended, you can see the variable values and add watches not only in the Debug tool window, but also inline in the code editor. Changed values are highlighted, making it easy to see what’s changed since the last time you hit the breakpoint.
Using the data received from the PHP debugger at breakpoints, PhpStorm displays in-editor hints about what will happen in the executed piece of code. Blocks of code in the path that are predicted to be unreachable are grayed out.
In addition to debugging, PhpStorm builds visual reports for the profiling data generated by Xdebug. You can select several snapshots at a time and collect the aggregated profiling information. In an aggregated report, you can jump from execution statistics directly to the relevant functions in your PHP code.