This tutorial describes how to get started with PHP web application debugging in PhpStorm IDE using Zend Debugger. Configuration for Xdebug is very similar, please see Zero-configuration Web Application Debugging with Xdebug and PhpStorm tutorial.
To use Zend Debugger with PhpStorm for debugging PHP applications, you need to have a PHP development environment configured with Zend Debugger extension installed. This task is beyond PhpStorm’s control. More information on configuring PHP development environment can be found in our web help.
Make sure that you have Zend Debugger installed properly. You can download the latest version of the Zend Debugger at its official website. Please note that your Zend Debugger version should fit the PHP version you have (mind the PHP version number and thread-safe/non-thread-safe option) and installed as zend_extension. Don’t forget to set the proper parameters in php.ini file. Detailed information on installing and configuring Zend Debugger can be found here.
You can check the configuration by executing php --version in the terminal
Alternatively, execute a page with phpinfo(); PHP function and make sure that you have Zend Debugger extension enabled. The Zend Debugger section of the document with the installed version should be available.
Toggle the “Start Listening for PHP Debug Connections” button. Don’t use any run configurations.
Apart from setting the breakpoint manually, you can use the option Run | Break at first line in PHP scripts to have an automatic breakpoint at the first line of every PHP script you debug.
In order to activate the debugger, you need to set a special GET/POST or COOKIE parameter. You can do it manually, but it is much more convenient to use one a special tool such as browser toolbar or bookmarklet for that.
Try our PhpStorm bookmarklets generator and get bookmarklets which will work in any modern browser and allow you to start/stop a debugging session by controlling the Zend Debugger cookie.
Names of menus and options may vary depending on your Internet browser. This section uses Firefox.
4.1. Enable your Bookmarks Toolbar (View | Toolbars | Bookmarks Toolbar)
4.2. Go to http://www.jetbrains.com/phpstorm/marklets/
4.3. Click the Generate button under the Zend Debugger section, then drag the links “Start debugger” and “Stop debugger” from the Debug section that appears to the Bookmarks Toolbar.
Switch to PhpStorm; you'll see the Incoming Connection From Xdebug dialogue. You'll now need to select the path mappings so that PhpStorm can map the remote files on the web server to the local files in your project. If you have a deployment configured, then PhpStorm will offer to configure the mappings based on the paths you've already set in that deployment.
If you have no deployment configured (or if the file mappings in the deployment are different), then you can select a manual file to use for this incoming debugger session.
After reaching the breakpoint the debugger is suspended. Now let’s investigate the application.
The first thing to check is that the Xdebug configuration is compatible with PhpStorm's configuration, you can do that using the Validating Your Debugging Configuration tutorial.
In some cases you may get the error message “Remote file path ‘path/to/script/on/the/server.php’ is not mapped to any file path in project“ or “The script ‘path/to/script/on/the/server.php’ is outside the project.” This means that PhpStorm is not sure which local file corresponds to the specified remote file path.
You can solve this problem quickly. Just set up the necessary path mappings by clicking the relevant link.