Debugging With PhpStorm

Get the most out of PHP debugging with PhpStorm and Xdebug.

Set and manage breakpoints

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.

Step through code line by line

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.

Test assumptions and know what your code does

Interactive debug window

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.

Inline debugger

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.

Data flow predictions

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.

Debug everywhere

Local and remote debugging

You get live debugging data for every line of executed code, even if the execution takes place on a remote web server – inside a Docker container, within a virtual machine, or on a remote host through SSH. Map the server files to their copies in your PhpStorm project, set up Xdebug, and enable listening to incoming debug connections in PhpStorm.

JavaScript debugging

PhpStorm comes with a full-scale JavaScript debugger from WebStorm. It supports both in-browser JavaScript and Node.js, and you can even launch the Xdebug and JavaScript debuggers simultaneously.

Debug inside Blade and Twig templates

Set breakpoints inside Blade and Twig templates and step debug them just like you would with PHP files. No template code reference in the compiled file? PhpStorm will warn you that the breakpoint you’ve set won’t be caught.

Debug HTTP API calls

You can debug HTTP requests to PHP servers right from PhpStorm’s in-editor HTTP Client. The IDE will automatically add the Xdebug cookie to the request, execute it, and stop at the specified breakpoint in the relevant PHP file.

View and analyze profiling data

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.

Offload the setup burden to your IDE

Xdebug configuration verification

PhpStorm sources data from the Xdebug installation on the local or remote web server to provide a flexible and powerful in-IDE debugging experience. To make configuration hassle-free, the IDE validates the debugger setup in the relevant environment and proposes fixes to the detected issues.

Zero-configuration debugging

With zero-configuration debugging, all you have to do is open the starting page of your PHP application in the browser and activate the debugging engine from there. PhpStorm will listen to incoming debugger connections and present you with the visual debugging data.