Xdebug breakpoints not working MAMP, PHPStorm

I had an issue with Xdebug not stopping at breakpoints except for the first line of code in only one of my local PHP projects.  Strangely enough xdebug_break() still worked everywhere I put it.  My first thought was that a PHPStorm project setting with the debugger was awry. After searching and trying many different php.ini settings someone suggested checking the xdebug logs for anomalies.

In your php.in file specify a Xdebug log path file and then restart apache.

  • xdebug.remote_log=/[path to where you want the log to live]/xdebug.log

After setting a breakpoint on line 7, running the script, checking the log, and seeing that my breakpoint was being registered, the only inconsistency I saw was the case in the file path.

<- breakpoint_set -i 10 -t line -f file:///Users/na/PhpstormProjects/Sample/httpdocs/index.php -n 7
-> <response xmlns=”urn:debugger_protocol_v1″ xmlns:xdebug=”http://xdebug.org/dbgp/xdebug” command=”breakpoint_set” transaction_id=”10″ id=”429140001″></response>

<- stack_get -i 11
-> <response xmlns=”urn:debugger_protocol_v1″ xmlns:xdebug=”http://xdebug.org/dbgp/xdebug” command=”stack_get” transaction_id=”11″><stack where=”{main}” level=”0″ type=”file” filename=”file:///Users/na/PhpstormProjects/sample/httpdocs/index.php” lineno=”4″></stack></response>

Turns out this particular project folder name was capitalized and others were not.  This was probably a project path setting within PHPStorm somewhere; however, I changed the folder to be all lowercase in the finder and Xdebug began working perfectly.

So if you can’t get a breakpoint to work, check the Xdebug logs and your project path names.  Hopefully this saves you from a few hours of frustration.

You may also like

2 Comments

  1. This was a really invaluable tip… had XDebug working correctly when the site was running on a Vagrant virtual machine, but spent ages trying to get it to respond when running with Nginx (homebrew) on the Mac itself. I would never have thought to look for a difference in case; turns out I had /users/ rather than /Users/ in the nginx docroot. As soon as this was fixed PHPStorm breakpoints started workng…

    Another issue for anyone struggling: before I even got to this stage, I change the XDebug remote_port from 9000 to 9001 (in the PHPStorm settings and php.ini), as 9000 is already used by php-fpm.

    The other thing you can do to troubleshoot is add an xdebug_break() statement to your code.

    Thanks again.

Leave a Reply

Your email address will not be published. Required fields are marked *