Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 27 Next »

This tutorial describes how to get started with PHP web application debugging in PhpStorm IDE using Xdebug. Configuration for Zend Debugger is very similar (just follow Zend Debugger installation guide and proceed from step 2 of this tutorial).

Error rendering macro 'toc' : [com.ctc.wstx.exc.WstxLazyException] com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "g" at [row,col {unknown-source}]: [20,25]

1. Install Xdebug

To use Xdebug with PhpStorm for debugging PHP applications, you need to have a PHP development environment configured with Xdebug 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 Xdebug installed properly. Please note that your Xdebug 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 xdebug.remote_enable setting to 1 in php.ini file. Detailed information on installing and configuring Xdebug can be found here. You can download the latest version of the Xdebug plugin at its official website. Recommended stable versions are 2.2.1 or 2.1.3.

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 Xdebug extension enabled. The xdebug section of the document with the installed version should be available.

2. Prepare PhpStorm

Toggle the “Start Listening for PHP Debug Connections” button. Don’t use any run configurations.

3. Set a breakpoint in the source code

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.

4. Activate debugger on server

In order to activate the debugger, you need to set a special GET/POST or COOKIE parameter (click here for details). 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 Xdebug cookie.

 How to add "Start/Stop Debugging" bookmarklets to your browser bookmarks toolbar

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

4.3. Click the Generate button under the Xdebug section, then drag the links “Start debugger” and “Stop debugger” from the Debug section that appears to the Bookmarks Toolbar.

5. Start a debug session in browser

6. Reload the current page

7. Set initial path mappings

Switch to PhpStorm and set the initial path mappings by selecting the path to the local copy of the script that you are debugging. These paths are similar if you are editing files directly on the server. The “Incoming Connection” dialog should appear automatically.

8. Debug!

After reaching the breakpoint the debugger is suspended. Now let’s investigate the application.


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.

  • No labels