PhpStorm and Xdebug

After showing last time how to connect PhpStorm with Redmine Today’s little blog post gives you a little tutorial, how to connect Xdebug and PhpStorm. Using Xdebug with your IDE gives you a lot of benefits. While clicking through the browser you can directly follow the code (by setting breakpoints) inside your IDE. You can find an introduction in Xdebug here and the whole documentation, surprise surprise, on

What do you need to follow this little tutorial?

  • PhpStorm
  • PHP including xdebug
  • Some basic knowledge, how to configure your PHP
  • The left part of your brain
  • A Linux/Unix-like operating system (Mac is fine)

I assume your PhpStorm is installed, and your PHP is working. First you may want to check in you phpinfo(), if xdebug is already installed. If not, then you need to install it (I did it using the pear repository):

pear install xdebug

Now as xdebug should be installed on your system, the next step is to activate the module. So add the following line in php.ini (if location is unclear, take a look at your phpinfo()):


YES, you need to declare it as zend_extension, trying to set it as will fail. If you restart your PHP (Apache/PHP-FPM/whateveryouuse) and take a look into your phpinfo(), you should see Xdebug enabled. Next, you need to make some basic configuration. Mine is seperated for each PHP module inside a conf.d directory. I cannot exactly say, where yours is, this depends on your PHP distribution. In the conf.d directory I have a xdebug.ini file where all Xdebug specific configuration is set (beside the module activation in the php.ini). My configuration:

xdebug.default_enable = 1
xdebug.max_nesting_level = 200
xdebug.scream = 1
xdebug.cli_color = 1
xdebug.collect_includes = 1
xdebug.collect_params = 4
xdebug.collect_return = 1
xdebug.dump_globals = 1
xdebug.idekey = PHPSTORM
xdebug.remote_port = 8999
xdebug.remote_handler = "dbgp"
xdebug.remote_host = ;set your local network IP here
xdebug.remote_enable = 1
xdebug.show_local_vars = 1
xdebug.collect_params = 4

Most important are idekey, remote_port, remote_handler, remote_host and remote_enable. Those are your settings to connect to PhpStorm. After another PHP restart you should see all your options as you configured them. Again, the Xdebug documentation is the place to go for a detailled description of all options.

Now, we need to configure PhpStorm to make use of Xdebug. Currently I use PhpStorm 4.0.2, there you find the options to set in

Preferences -> PHP -> debug
Set the following settings, and check if you really follow them, if you are unsure, what you are doing.

PhpStorm debug configuration

PhpStorm debug configuration

Next, configure the details in the DGBp proxy settings (Attention: set the host to that one you use on your local machine, I use test.local for example):

PhpStorm DBGp debug settings

PhpStorm DBGp debug settings

Now you are very closed to the end of this tutorial. To use the debugging, you need to restart your PhpStorm (at least the changes did not take effect on my machine until I did it) and to set your browser bookmarklets. You need some to send a cookie that tells Xdebug and PhpStorm to connect.

You can create those bookmarklets here. Best Practice: put them into your Firefox bookmark toolbar. A helper plugin can be found here, but I did not test it.

That’s it! Please share your experiences, so this tutorial can be enhanced.

Tagged ,

One thought on “PhpStorm and Xdebug

  1. seb says:

    Thanks for this guide! I’ve used this setup before but it’s always a pain and you solved my problems this time. Thank!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>