Skip to main content

Configuring Xdebug and phpstorm for CLI debugging

This blog post might be outdated!
This blog post was published more than one year ago and might be outdated!
· 2 min read
Stephan Hochdörfer
Head of IT Business Operations

Current situation: I have no local webserver running and just php5-cli (plus a few extensions) installed as most of the development I do will make use of a Vagrant machine. From time to time I develop small tools or libs which I like to debug on the command line. This is an overview how I configured my Ubuntu 14.04 box to handle debugging with Xdebug and phpstorm.

Install the Xdebug extension via pecl:

sudo apt-get install dh-make-php php5-dev
sudo pecl install xdebug

Create xdebug.ini config file in /etc/php5/mods-available/xdebug.ini:

; configuration for xdebug module
; priority=20


Enable the xdebug extension:

sudo php5enmod xdebug

Add environment variables to ~/.bashrc (and reload it afterwards):

export PHP_IDE_CONFIG="serverName=localhost"

Configure phpstorm:

In Settings > Languages & Frameworks > PHP > Servers create a new entry. Give it a name (e.g. localhost) and set the Host to "localhost" (needs to match the serverName defined in your PHP_IDE_CONFIG environment variable. Set the port to 80 and choose Xdebug as a debugger. No need to validate the settings.

This is all it takes. Now turn on the debug mode in phpstorm, set a breakpoint and run your script. phpstorm should be able to communicate with Xdebug now.