Sunday, April 27, 2014

Zend Studio V10 Ignores Breakpoints

There are multiple causes for this problem.  The most common reason is because you are doing remote debugging and Zend Studio does not correctly identify the code base associated with the remote pages.  You can easily tell this is what is happening because when the debugger opens up the start page, the path to it will not start with your Zend Studio project name.  It will be the actual physical location or the remote server.  Further, if you set breakpoints in your project, you won’t see them in the remote project.  You can still debug in a situation like this by putting sleep(10); commands in the code, and then just manually pausing it in the debugger.  But it’s annoying, and you are better off trying to fix your project settings by manually entering the URL that matches to the project in the debug settings.

However, there is another cause of this problem which is a straight up bug in Zend Studio.  And if you use the same project for a long time, you are bound to eventually run into it.  I have seen this issue with versions of Zend Studio going back to version 7.2 (I am not saying it didn’t exist before that, but that’s the first version I can definitely say I’ve seen it in), and it still exists in version 10 (which I am currently using).  One day, Zend Studio just starts ignoring breakpoints in some specific file.  You can set breakpoints in the calling method, but if you set it in method X, it will ignore it.  If you put in the above sleep command, and then you pause it, you will see your breakpoints in the file, but Zend Studio just fails to respect them.  And the situation will gradually deteriorate until Zend Studio simply will not stop for any breakpoint anywhere.

At this point, you need to delete the project in Zend Studio (make sure you don’t delete your source files).  Now go to the directory where the project is located, and do a:

rm .buildpath
rm .project
rm –r –f .settings

And now go back to the PHP Explorer tab and recreate the project from existing source.  If you have any custom items in your PHP build path, you’ll have to redo them.  That’s unfortunate, but this is the only way I’ve found to fix this problem.  Fortunately, it’s fairly rare, and you’ll likely be able to use it for several months or even years before this starts to happen.  Because it takes so long for it to show up, and it’s seemingly random, I have no idea what causes it to happen and cannot offer any advice on how to avoid it.


But it’s definitely a bug in Zend Studio and not any kind of misconfiguration as it affects projects that have been working perfectly for months or even years in some cases.