Categories
Mac PHP

Debugging with XDebug and PhpStorm on MacOS X

In an earlier post I demonstrated how to install PHP5.4 using brew. Today, I required xdebug for debugging purposes and found it quite easy to install via homebrew.

Install XDebug for PHP
It’s as simple as issuing the command:

Enabling XDebug
I had to add the extension to my php.ini file:

Follow the output of the brew info output of the package you installed (either php53 or php54):

To enable remote debugging, I also added these lines:

Debugging Web Applications
In the run configuration, add “Web Application” type. Configure the server and path as usual. When setup, you shall notice the debug button is active. Setup some break points and hit the debug button.

You can also use the “Listen PHP Debug Connection” option along with some xdebug bookmarklet for quick debugging.

Debugging Command Line Scripts
To debug command line scripts, first issue this command on terminal:

PS: I added the line to my ~/.bash_profile so that I don’t have to type it every time I login to bash shell.

Turn on incoming connections by clicking the “Start Listen PHP Debug Connection” button. Set some break points and then run the script from command line.

4 replies on “Debugging with XDebug and PhpStorm on MacOS X”

you are very active in your blog.I get lot of inspiration from you.really you r hard working person.keep it up!!!!

In your php.ini put this instead:

(replace php54-xdebug with the correct version, of course. e.g. php56-xdebug)

That way you don’t have to update the hard coded version in the file path for every homebrew xdebug update.

 

Comments are closed.