Debugging PHP in Atom by installing xdebug, in 5 minutes

Install xdebug

There are plenty of tutorials that suggest using Homebrew to install xdebug, I found none of these worked nice one homebrew.

After digging around a bit I found that xdebug actually has a configuration wizard. To get set up with this create a create a <?php phpinfo();?> file in your environment and copy and paste the content into the wizard. The wizard tells you what to do next.

Check its installed with terminal

$ php --version

Enable xdebug in MAMP

xdebug by default outputs its debug info to port 9000, and by default xdebug isn’t configured in MAMP to output to 9000. Have a look at this post post

Quick Tip – Enabling XDebug in MAMP for OSX

Make sure you are editing the php.ini for the correct version of PHP, these are in /Applications/MAMP/bin/php/php7.x

Installing Packages in Atom

The best package I have found for atom is php-debug

Press CMD + , to bring up settings, got to install packages and search for php-debug.

Use Packages > PHP-Debug > Toggle Debugging and run a php file in MAMP and everything should be working.

Back to Top