Very rarely, do I come across a configuration problem I can not easily find the solution. Sometimes despite all my searching, solutions to problems just haven’t been posted yet. This is the solution to something I’ve been needing for a very long time:
You are a PHP developer who uses Eclipse PDT, or netbeans IDE, or something else and needs to debug via xdebug. If you have ever come across the problem where setting breakpoints ONLY seems to work in index.php, here is the solution:
Simple explanation is if you have soft-links in your php include path, or if you are using a case-insensitive file system (OSX), the path of the breakpoint your setting in your IDE must EXACTLY match the path where php loads the file from. In my case, both of these conditions were the root cause of my debugger not stopping on my breakpoints in my IDE.
Here was my configuration:
I set the include path in my .htaccess file. Lets just say I set it to something like:
And lets say that in htdocs, I’ve got two files index.php and MyClass.php. Now, in my case the path “/Applications/xampp/htdocs” is actually a softlink to “/Applications/XAMPP/xamppfiles/htdocs” (notice the upper-case). Now, this is all fine and dandy. Php works fine, it finds the path on the filesystem, and loads up my files without php problems… However, when I debug in Eclipse PDT, breakpoints only work in the index file…. WTF? So I enabled xdebug logging, and I saw the that debug client was telling xdebug to break inside MyClass.php, but the path of the file it was breaking on was
Php loaded the file at: (due to what my include path is)
Yes, it’s the same file, but i guess xdebug just can’t figure that out. Simple solution, throw an xdebug_break() in the file you want to breakpoint on…. This should always work. Have a look at your stack and check the path of the file that the breakpoint is on… Make sure that that path is exactly the one your using in your include path in php…. CASE SENESITIVE AS WELL….
At first I thought this was a php 5.3 problem (as the problem just started when I upgraded to 5.3, however that’s when xampp project decided to use CAPITALS XAMPP instead of lower-case)… Then I thought it had something to do with mod rewrite…. Nope. If breakpoints work in your index file they should work everywhere else… If they’re not, it’s a PATH problem.
In my case, I just changed my php include path from
and VOILA! All breakpoints work again. 🙂