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.

Continue Reading

Configure Windows 7 with MAMP virtual hosts and Virtual Box

I’m using MAMP Pro for local web development on OSX Lion and needed to test some javascript compatibility with IE so I booted up a virtual machine. It took me a few minutes to figure how to have the DNS resolve to my local development domains that were set up on my main OS.  I couldn’t find this tip immediately online so here it is.

If you want to be able to access your named virtual hosts that you set up on MAMP on a Windows 7 virtual machine make sure you update your hosts file on the Windows VM.

Here’s what works for me.

  1. Install MAMP Pro
  2. Setup local development host in MAMP
  3. Install Virtual Box
  4. Setup Windows 7
  5. Edit the Windows 7 hosts file
    1. Run Notepad as admin in Windows.
    2. Open C:\Windows\System32\drivers\etc\hosts
    3. Add 10.0.2.2 yourdevdomain
      • Add more if you have want.
    4. Save the file.
    5. Instance restart may be required.
If that doesn’t work, check what port Apache is running on and edit the hosts file accordingly.

Continue Reading