Setting up xdebug for PhpStorm on OSX
Maybe it was only me, but it really took me quite long to figure out how to enable xdebug for Phpstorm and debug my php code with it, now I have to record this whole process.
1. Install PHP and xdebug
The PHP comes with the OSX isn’t optimal for what we want to do here, since we plan to use Homebrew as our package management software as much as possible. You can install PHP with following command:
2. Enable xdebug
Now the xdebug is installed, we want to enable it. The
ini file for brewed PHP should be at
/usr/local/etc/php/5.6/conf.d/ext-xdebug.ini. It should contain:
here the very important attributes are
3. Configure PhpStorm
In Phpstorm the configuration for xdebug is at
Preference > Languages & Framework > PHP > Debug > Xdebug remember to change the debug port to what we have in previous step and mark
Can accept external connections.
4. Debug with Xdebug in PhpStorm
Now open your project and click on the
listen to the debug button connections in PhpStorm.
Set a break point by click on the gutter of your code. Then start your php server and open the page you want to debug, append this query
?XDEBUG_SESSION_START=true at the end of the url, refresh page …
Voila, now you can debug your code in PhpStorm with xdebug!