Debugging with XDebug and PhpStorm (add-on)

Good day,% username%!

I read today the article “Debugging with XDebug and PhpStorm on the example of 1C-Bitrix website” . In it, the author uses the "green bug" to run debugging. The comments suggest several more methods for starting debugging, such as special bookmarks, various plugins, etc. In my opinion, all this is inconvenient, besides there is the most simple and convenient option. I could offer it in the comments to the article, but, alas, in read-only this is not possible. Therefore, I have to write a separate article.

Xdebug has the ability to auto start, without any tricks. Simply place breakpoints and open your application in a browser, xdebug will pick up the start itself.

So my configuration is:
  • Web Server - OpenServer 4.8.8
  • PHP 5.4.17
  • XDebug 2.2.3
  • IDE PhpStorm 7.1.


1. Configure XDebug

In php.ini we connect the extension and set the parameters:
zend_extension="%путь до php%/ext/php_xdebug.dll"
;эта опция как раз и отвечает за автостарт
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_handler="dbgp"
xdebug.remote_host="localhost"
;порт может быть и 9000, но у openserver он зарезервирован под php
xdebug.remote_port=9001
xdebug.remote_mode=req
;ключ IDE (может быть любым) понадобится позже
xdebug.idekey="PHPSTORM"

2. Configure PhpStorm

We configure the interpreter if you have not done so already.

image

image

Next, add the server, if you are a local server, then write in the Host - localhost field , if the remote address is the remote host. The hostname here and in php.ini must match.

image

Configure XDebug. We take the port from php.ini (xdebug.remote_port). If you do not need XDebug to stop on the first line of the application, disable the two lower checkboxes.

image

Here we also take values ​​from php.ini: IDE key -> xdebug.idekey, Host -> xdebug.remote_host, Port -> xdebug.remote_port.

image

On this setup is completed, you can use.

Using

To get started, set breakpoints, turn on the XDebug port wiretap and open your application.

image

image

Breakpoints will be caught automatically, without the need to poke a "green bug". I hope the information is useful to someone.

That's all, thanks for your attention.

PS The article has been hanging in the sandbox for about a year, but is still relevant, so I publish it. Thanks to jeston for inviting me .

Also popular now: