This post is an explanation of the Zero-configuration Web Application Debugging with Xdebug and PhpStorm wiki entry over at JetBrains.
While the instructions are pretty straight forward, I wanted to share where being a beginner had me scratching my head wondering why things weren’t working. Enjoy!
1. Install Xdebug
I stumbled upon a wizard to help me get Xdebug installed on my system (OS X Yosemite using local MAMP). You can find the wizard here, which will give you step-by-step instructions specifically for your current environment.
1. a. Configuring Xdebug
Here is what I added to my
php.ini file (values left as <explanations>):
zend_extension=”<this was already added as part of Install Xdebug step>” xdebug.remote_enable=1 xdebug.remote_port=”<the port for XDebug to listen to>” (the default port is 9000) xdebug.profiler_enable=1 xdebug.profiler_output_dir=”<AMP home\tmp>”
More about how to configure Xdebug can be found here.
After updating the
php.ini file, I restarted Apache (
sudo apachectl restart).
2. Prepare PhpStorm
Probably the most straightforward step!
3. Set a breakpoint in the source code
Find an area in your code that you want to debug and click the gutter before the line of code to set break point.
4. Activate debugger on server
I’m currently using the bookmarklets to activate/deactivate the debugger.
Note: To bookmark, I found it easiest to click and drag the link to my Bookmark Bar in Chrome.
5. Start a debug session in browser
Nothing will seem to happen when clicking on the bookmark, but not to worry, proceed to the next step!
6. Reload the current page
Here’s where the code should stop executing (your page should “pause” it’s loading) and PhpStorm will now be at the forefront with its debug window open.
7. Set initial path mappings
I skipped this step. Your mileage may vary here.
Step into functions, check what variables are set as, etc.
There you have it! Let me know via a comment if you ran into any other issues or have any tips to improve upon the install / debugging process with PhpStorm.
Special thanks to @chaplinkyle for his recommendation to use PhpStorm.