Skip to main content

Remote-Debugging using XDebug and PHPStorm

Category: PHP
php-logo

Configuration of PHPStorm

By default the remote debugging port is set to 9000. This can be easily changed in the general settings. For now we gonna use the default.

First we need to select "Run -> Edit Configurations..."  at application's menu. There we should add a "PHP Remote Debug" configuration type. Afterwards we have to define informations about the server (url, port, debugger and paths) like in screenshot below. Those settings are made for a server running at localhost, but can be easily adopted for a docker container or a vagrant box.

PHPStorm - Serverkonfiguration

Now we need to define the "Ide key".

PHPStorm - Ide key

Configuration of XDebug

The following settings only refer to remote debugging and should be extended as you wish in php.ini:

; activating Remote-Debugging
xdebug.remote_enable=1
xdebug.remote_autostart=1

; host definition
xdebug.remote_host = localhost
xdebug.remote_port=9000

; Remote-log path
xdebug.remote_log=/tmp/xdebug.log

; Ide-Key
xdebug.idekey=phpstorm

; this activates remote debugging for every host,
; this option is overwriting remote_host
;xdebug.remote_connect_back=1

Now you'll have to restart the server.

Installation and use of chrome extensions

Download: JetBrains IDE Support

Thanks to assistance of this extension, we do not have to add GET-/Cookie-Params ourselves. Just right click the extension's icon and choose "Inspect with PHPStorm".

And finally...

... switch back to PHPStorm, select "Run -> Debug" at the menu for selecting our just made configuration and with "Run -> Start Listening for PHP Debug Connections" we are ready to debug. We just need to set a breakpoint (by clicking it's line number) and reload the page in browser.

Debug content

Troubleshooting

sudo tcpdump -ni eth1 -n port 9000 -X     

By using tcpdump you can check whether data is send or not.

Monthly archive

Categories

Debian (2)

Git (4)

Jira (1)

jQuery (1)

Linux (2)

MySQL (1)

PHP (1)