• [SOLVED] Debugging custom manager page in NetBeans - breakpoint doesn't work.#

  • javadecaf Reply #1, 10 months, 3 weeks ago

    Reply
    I'm hoping there's someone else out there who has run into this issue in NetBeans, but it may apply to other IDE's as well. I have created a custom manager page per the tutorial and I'm having some trouble with it. For testing purposes, I trimmed index.php down to just 2 lines of code:
    $output = "Houston, we have a problem.";
    return $output;
    

    I set a breakpoint on the first line, and fire up my debugger (xDebug, which works great on front-end pages). Usually, a green arrow would pop up on the breakpoint, but on this page, I get no green arrow, and no indication of what line will execute next. The only way I can tell where I am is to look at the call stack, which gives the current function as "core/components/mycmp/index.php.{main}:29]".

    Does anyone understand this syntax? My index.php has only 2 lines - why is it referring to line 29? (Incidentally, it has started on that number every time, even before I reduced the file to 2 lines). What does {main} refer to? And why is my breakpoint not working? I can hit F5 until the page loads completely in the browser, and the result is as expected ("Houston, we have a problem" is displayed on the screen) but execution never halts on breakpoint.

    Can anybody help me out here?
    (BTW, on forum posts, I know the syntax for code and PHP syntax highlighting, but I can't seem to combine the two. Does anyone know how to do that?)


  • shamblett Reply #2, 10 months, 3 weeks ago

    Reply
    Try using the 'debug file' option rather than the 'debug main project' one, also select 'do not open web browser' in the advanced web configuration' options.


  • javadecaf Reply #3, 10 months, 3 weeks ago

    Reply
    Quote from: shamblett at Jun 28, 2011, 11:02 PM
    Try using the 'debug file' option rather than the 'debug main project' one, also select 'do not open web browser' in the advanced web configuration' options.
    Thanks, but I'm already doing both those things.


  • opengeek Reply #4, 10 months, 3 weeks ago

    Reply
    I really recommend trying PhpStorm. It's not free, but you can try it for 30 days and, well, it just works when it comes to debugging and many other things...


  • javadecaf Reply #5, 10 months, 3 weeks ago

    Reply
    Thanks for the suggestion - I'll give it a try.


  • javadecaf Reply #6, 10 months, 3 weeks ago

    Reply
    OK, after a few hours of testing the strength of a brick wall with my head I finally found the solution (with some help from robinK via PM). I probably should have mentioned in the initial post that I'm using remote debugging, my IDE being on a different machine from my local webserver. In NetBeans, this may (and in my case, does) require that you specify Path Mapping for the project, so it knows where to find the files for debugging. To do this, go to Project Properties -> Run Configuration -> Advanced, enter the server path for your project (e.g. /var/www/mywebsite.com) and click the little gray button to navigate to the project folder (e.g., \\mywebserver\mywebsite.com). Save your configuration, and everything should work together nicely.

    As a side note, my program execution is still pausing at places where I haven't set breakpoints. This isn't a major problem, since I can just hit F5 until I get to the real breakpoint(s), but I wouldn't mind fixing it if anyone has a clue what might be happening.


  • javadecaf Reply #7, 10 months, 3 weeks ago

    Reply
    Quote from: javadecaf at Jun 29, 2011, 02:06 PM
    As a side note, my program execution is still pausing at places where I haven't set breakpoints. This isn't a major problem, since I can just hit F5 until I get to the real breakpoint(s), but I wouldn't mind fixing it if anyone has a clue what might be happening.
    Well, I just resolved this one, too, so in the interests of complete documentation, here's the fix. In NetBeans, go to Tools -> Options, choose the PHP tab, and under "Debugging," uncheck "Stop at first line".

    "And they all lived happily ever after!" (or until the next bug, anyway)