Debugging, Testing and Profiling

Visual Debugger

PhpStorm provides numerous options for debugging your PHP code. Inspect context-relevant local variables and user-defined watches, including arrays and complex objects, and edit values on the fly. Set up remote debugging for your server, evaluate an expression in runtime, debug a page in multiple sessions simultaneously, keep a debugging session alive while moving between pages, and more.

Zero-Configuration Debugging

With zero-configuration debugging, you do not need to create any debug configuration. Instead, you open the starting page of your PHP application in the browser manually, and then activate the debugging engine from the browser, while PhpStorm listens to incoming debugger connections. Both Xdebug and Zend Debugger are supported.

Read more about zero-configuration debugging with PhpStorm.

And when (in some cases) you still need to configure debugging manually, read this article: How to configure debugging in PhpStorm.

Debugger Configuration Validation

There is nothing more frustrating than not getting PHP Debugging to work because of some configuration error in php.ini.

When configuring the PHP interpreter for project, PhpStorm will inform you if a debugger is installed and will yield the Xdebug or Zend Debugger version. From PHP Servers Settings window, you can validate the debugger setup: you can test the remote environment on which you want to use the debugger and validate the debugger configuration. PhpStorm will tell you if anything is missing, and how to fix that.

Inline Debugger for PHP

With an inline debugger for PHP, all live debugging data are shown directly in the editor, with variable values integrated into the editor interface. Variable values can be viewed in the source code, right next to their usages.

XDebug for REST Client

PhpStorm has a button in the REST Client that sends the HTTP request with the right cookie automatically set. Thus debugging of RESTful Web Service can be done right from within the REST Client, without leaving the IDE.

Debugging with Smart Step Into

This debugging feature allows you to choose the function to step into while debugging. This functionality also works with dynamic function calls.

Zend Server Integration

PHP debugging and profiling sessions can be activated from Z-Ray and Zend Server interface to take action in PhpStorm.

Interactive Debug Console for PHP (REPL)

Interactive debug console (REPL) allows you to alter variables, call PHP functions, and define additional functions – all on the fly within the debug session.

Unit Testing With PHPUnit

Develop PHPUnit tests right in PhpStorm and run them instantly from a directory, file or class using the context menu options. PHPUnit versions higher than 3.3 (including PHPUnit 10) are supported.

Unit Testing With PHPUnit

PHPUnit can be run locally or on server (in which case it can be configured with an XML configuration file). Dedicated Run/Debug configurations allow you to run the appropriate set of tests at a later time.

Test Runner

Tests are executed in a dedicated Test Runner UI, displaying an overview of results as well as detailed stats for the whole suite and every particular test. If a test fails, you can instantly jump from the stacktrace to the line of code where the error occurred and rerun only failed tests after issue is fixed.

Code Coverage

Code Coverage for PHPUnit shows you how much of your code is covered with tests, marking covered and uncovered lines visually right in the editor. Code coverage analysis with PHPUnit is fully supported in PhpStorm.

Testing with Behat, PHPSpec, and Codeception

Behat

BDD is now possible in PhpStorm with Behat. Write human-readable stories that describe the behavior of your application, with installation and configuration helpers, run configuration and Behat Intellisense available.

PHPSpec

Code completion, navigation and proper inspections are available when working with PHPSpec in PhpStorm. PHPSpec run configurations will help to run the PHPSpec easily.

Codeception

Codeception testing framework, starting with version 2.2.0, is supported. You can install it from Composer or PHAR. Run Configuration will help you run your tests locally, on a Vagrant machine, remote interpreter, or Docker.

Profiler Integration

You can profile your applications right from the IDE with either Xdebug or Zend Debugger. PhpStorm provides a visual representation of profiling data generated by Xdebug or Zend Debugger. You can select several snapshots at a time and collect the aggregated profiling information. Observe an aggregated report and jump from the execution statistics directly to the function in your PHP code.