Xdebug only works if breakpoint is on first line of script

Has anyone else noticed this?  I'd like to be able to stop anywhere in script rather than just first line.  I'm using the zero config method.

Comment actions Permalink

Hi there,

It has to be your machine/code specific -- it works fine here on Windows 7 x64; xdebug 2.2.3 and PHP 5.4.19. What's your xdebug version?

Please note that xdebug is unable to break if breakpoint is set on certain lines (due to the way how PHP generates the byte code), e.g. multi--line variable/array definition; if statement with no braces etc. What kind of code you have there (breakpoints)?

In any case: "Run | Break at first line in PHP scripts" -- try turning it on/off few times. Sometimes it stuck (for unknown reason) and wrong status is displayed -- maybe (just maybe) it may affect your situation as well.

Comment actions Permalink

Thanks for the quick response.

I'm on xdebug 2.2.0.  I'm on OSX 10.8.4 using mamp on PHP 5.4.4

I've just noticed it works on another project fine but the other one it will still only stop on the 1st line.  I tried ticking and unticking the run option.

The lines are normal single decleration lines.  If I comment the 1st line and put a breakpoint on the second it will stop there, ie they are 'stoppable' lines.

Comment actions Permalink

Well .. if it works in another project .. and it woks if first line is commented .. then it's possible that problem is in actual files. See if you can change anything about them (e.g. re-type first 2 line manually ... or maybe copy and paste back and then save -- things like that).

On another hand -- I recommend upgrading your xdebug. v2.2.0 is quite unstable (has some issues) -- minimal recommended version is 2.2.1 (latest stable is 2.2.3).

Can you please show what kind of lines they are (I'm curious about that -- why it behaves that way) -- screenshot is enough.

Comment actions Permalink

You can also try re-configuring this particular project from scratch (in case it's some kind of project settings issue):

  • Close project in IDE
  • Backup and delete (or just rename) .idea subfolder in your project root (that's where project settings are stored)
  • You can open that project again via "File | Open Directory"
Comment actions Permalink

Hi Andriy

Here's an update,  I've spent a day battling with xdebug 2.3.3 compiling.  It's very tricky with MAMP on OSX, there's loads of things missing and the compiler process refers to the original OSX version for files.  So I eventually managed to compile the right version on a virtual machine with a fresh install of PHP.  

So now I have 2.3.3 version running OK but I'm still only able to break on the 1st line.  I closed the project in question and renamed the .idea folder to no avail.  I've created a real simple script to demonstrate the issue.  It's literally just this...

echo "1st line";
echo "2nd line";

I've now found 2 projects that I can break anywhere, it seems the difference with them is

A/ They have a name in the window drop down not a path,(why is that, I can't see a name setting anywhere)
B/ They use a different virtual host mapping pattern in my apache config.

Comment actions Permalink

Unfortunately I'm not a Mac user and have no way of testing/reproducing anything like that here.

Your description (the difference between projects: A) and B) ) does not give me any clues on what may be wrong and where (I'm using Windows 7 and IIS 7.5 here; but even back then when I've used Apache, it always worked for me (yeah, Windows for the win :) )).

Maybe somebody from dev/support team will be able to help you here. If you will not see any response from them within 2-3 days just create new ticket on Issue Tracker with as many details as possible.

The only other thing I may suggest right now is to try and collect debugger logs (but I do not really expect this to be very useful). 1) Logs need to be collected from both PhpStorm side as well as xdebug; 2) attemp to debug your code:

Comment actions Permalink

OK I will do, thanks for your help.

Just out of interest do you know why some projects are refered to by name and others folder in the window list.  This is what I see

Screen Shot 2013-09-05 at 18.29.28.png
The ones that work are C1 and loreal-nutrisse

Comment actions Permalink

Well .. see if "File | Rename Project" will help here (I'm thinking  -- maybe you gave some projects custom name .. and some where left as is).

BTW -- have you tried with re-configuring project from scratch (deleting .idea folder as I have suggested) ?

Comment actions Permalink

Yes I did try that and it didn't work.  OK I've found some more out.  Renaming the project didn't help
so it's not that.

if I move a project from one virtualhost to another it works, then I move it back to the original location and it stops working so it's something to do with the server name or virtual hosts.

<VirtualHost *:80>
    VirtualDocumentRoot /Users/stu/Projects/Hearst/commercial/%3/%2/%1
 ServerAlias *.commercial.hearst
<VirtualHost *:80>
    VirtualDocumentRoot /Users/stu/Projects/%-1/%-2+/web
 ServerAlias *.*

The 1st one works and the second doesn't

so in my browser I'm using http://web.rimmel.common.commercial.hearst/debugtest.php  (works)


http://rimmel.hearst/debugtest.php (fails)

I just found this, looked like it could of fixed but didn't  http://stackoverflow.com/questions/9416505/xdebug-hangs-on-virtual-hosting-domains :(

I'll check the logs now

Comment actions Permalink

Wow I've had a break from this issue cus it was driving me nuts.  Had a bit of time today, so I removed Mamp as I've conluded it doesn't play well with command line tools.  I reinstalled PHP / Mysql using homebrew and got xdebug installed.  The error still existed.  So I was just filling in a youtrack with my log files at the ready and I notice some links appear as I was typing, specifically this one http://youtrack.jetbrains.com/issue/WI-18579

There's some underlying weirdness between apache, xdebug, finder, terminal and PHP storm when it comes to case sensitivity.  I renamed all folders where any sites are hosted to lowercase using mv.  I had to restart PHPstorm and boom I can now stop anywhere.  

So to anyone using vhosts make sure all folders are lowercase, especially if your using 'Directory Name Interpolation'

Comment actions Permalink

Excellent observation, Stuart!

I've been having the same issue as you (Xdebug only breaks on the first line and then you would even have to set a breakpoint there first)
and lost hours, even days with this.
My documents were in the folder /Library/Webserver/Documents/
When I changed this to /www/ and rebooted PHPStorm Xdebug started breaking on whatever/wherever breakpoint I set in my code.

Everything was fine in the beginning:
* Xdebug installed correctly
* PHP installed correctly
* ports set correctly
* PHPStorm options set correctly (allow incoming external connections, listen to incoming connections, remote server setup, path mappings, ...)
* debugger started with either XDebug Helper in Chrome or with xdebug.remote_autostart =  1 in the ini
but nothing worked, it always kept breaking on the first line, until I read your post.

Many thanks!



Please sign in to leave a comment.