Category: Development

Debugging with XDebug and PhpStorm on MacOS X

Author(s)

Simon
Simon
So you have phpstorm and you want to debug your app step by step using Xdebug?

Install Xdebug for PHP

Homebrew make things simple. You will also need homebrew-php to have PHP-related formula.
brew install php54-xdebug
When the installation is done, brew give you some info:
To finish installing xdebug for PHP 5.4:
  * /usr/local/etc/php/5.4/conf.d/ext-xdebug.ini was created,
    do not forget to remove it upon extension removal.
  * Restart your webserver.
  * Write a PHP page that calls "phpinfo();"
  * Load it in a browser and look for the info on the xdebug module.
  * If you see it, you have been successful!
If you miss it and clear your terminal, you can get those info back with the following command.
brew info php54-xdebug
I'm using php-fpm so I just retart php-fpm.
To check xdebug was installed I used the php-cli, you can also use phpinfo(). Both should contain the xdebug configuration.
php -i | grep xdebug

Configure XDebug and PHPStorm

I had to change the default port of xdebug because 9000 is taken by php-fpm on my machine.
So configure /usr/local/etc/php/5.4/conf.d/ext-xdebug.ini like that:
[xdebug]
zend_extension="/usr/local/Cellar/php54-xdebug/2.2.3/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port=10000
xdebug.remote_handler="dbgp"
xdebug.remote_host="localhost"
xdebug.idekey=
And also change the port on phpstorm : 

Launch a debug session

On phpstorm from the menu: Run -> Start listen PHP debug connections.
Screenshot showing the Xdebug parameters to setup : Debug port = 10000
With Firefox and https://addons.mozilla.org/en-US/firefox/addon/the-easiest-xdebug/ you can quickly enable xdebug. On the addon's preferences set the IDE key to "PHPSTORM" (or the one you set in the phpstorm's preferences if you changed it). You then just have to refresh the page, phpstorm should then automatically start a debug session.

More articles

Author(s)

Akira
Akira

Making of : “La nuit des Losers”

lanuitdeslosers.ch, built fast: paper wireframes, a bold hand-drawn identity, then Claude Code to prototype and ship. A mouse-tracking hero animation, a bowling game made of sponsor logos, and a few bugs we’re keeping.
lanuitdeslosers.ch, built fast: paper wireframes, a bold hand-drawn identity, then Claude Code to prototype and ship. A mouse-tracking hero animation, a bowling game made of sponsor logos, and a few bugs we’re keeping.
Making of : “La nuit des Losers”

Author(s)

Pierre
Pierre

Dark mode: necessity or trend

Nous faisons le tri entre idées reçues, réalités techniques et bonnes pratiques de design.
Nous faisons le tri entre idées reçues, réalités techniques et bonnes pratiques de design.
Dark mode: necessity or trend

Author(s)

Yann
Pierre
Yann and Pierre

Experiment #2 – Surway, a social experiments game

Pour notre deuxième expérimentation, nous avons relevé le défi de sortir de notre zone de confort en développant Surway, un jeu vidéo jouable directement dans le navigateur, où les actions de chaque joueur restent inscrites pour tous ceux qui suivront.
Pour notre deuxième expérimentation, nous avons relevé le défi de sortir de notre zone de confort en développant Surway, un jeu vidéo jouable directement dans le navigateur, où les actions de chaque joueur restent inscrites pour tous ceux qui suivront.
Experiment #2 – Surway, a social experiments game