Xdebug in Netbeans: not stopping on breakpoint inside file in “web root's” parent folder

那年仲夏 提交于 2019-12-08 02:08:03

问题


I have a netbeans project with a directory tree like this:

<source folder>
|
|---> gui <web root folder>
|      |
|      L---> datos.php
|
L---> index.php

datos.php changes the working directory to .. (source folder) and includes index.php like this:

chdir('..');
require 'index.php';

If I put a breakpoint inside datos.php, the debugger breaks on it correctly, but when putting one in index.php it ignores it.

The strange thing is 6 months ago I had the same problem and I was able to fix it. Now I don't know why it stopped working and what I did back then to fix it.

More info:

xdebug log shows the following command for breakpoint setting:

breakpoint_set -i 315 -t line -s enabled -f file:///Users/tomasgirardi/NetBeansProjects/datamed/index.php -n 51
breakpoint_set -i 316 -t line -s enabled -f file:///Users/tomasgirardi/NetBeansProjects/datamed/gui/datos.php -n 39 

In both cases xdebug responds with state="enabled"

And if I debug manually, I can use the following command to set the breakpoint, which works:

breakpoint_set -i 315 -t line -s enabled -f file:///../index.php -n 51

But I don't know how could I make netbeans issue the breakpoint_set command with the same file:///../index.php argument and not file:///Users/tomasgirardi/NetBeansProjects/datamed/index.php or any other way I can make this work.

Thanks in advance for any help!


回答1:


You always can try using xdebug_break();

For example :

<?php
    for ( $i=1, $j=0; $i<10; $i++) { 
        xdebug_break();
        echo "<br>Line $i";   // will stop here
    }
?> 

will add a breakpoint in the following line.

Hope that helps a little...




回答2:


Breakpoints are working again. I don't have any clues to why they didn't worked before but now they do. I can't remember doing any changes in xdebug or Netbeans either.

xdebug.log shows me the same as before, but now it stops at the setted breakpoint:

<- breakpoint_set -i 4 -t line -s enabled -f file:///Users/tomasgirardi/NetBeansProjects/datamed/index.php -n 51
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="4" state="enabled" id="14290001"></response>

<- run -i 5
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="5" status="break" reason="ok"><xdebug:message filename="file:///Users/tomasgirardi/NetBeansProjects/datamed/index.php" lineno="51"></xdebug:message></response>

However, if anyone knows why this could had happend, sharing it could be helpful either way: probably me or someone else will be able to avoid having similar troubles in the future.




回答3:


This issue is more specific to people who are using remote servers for their web apps.

I had the same problem. Xdebug ignores breakpoints really helped me however i have given solution more specific to netbeans, but the essence is the same, which ever IDE you are using. Just map your local project path with your remote server path.

My environment is WINDOWS 7 and website is hosted on UBUNTU VM. I am using NETBEANS from Windows 7 and has setup a remote project.

My xdebug logs

<- breakpoint_set -i 4 -t line -s enabled -f file:///C:/Users/ali/Documents/NetBeansProjects/test.com.au/cgen/src/Acme/TestBundle/Controller/CreateController.php -n 39

->

The real problem was the project path in netbeans [C:/Users/ali/Documents/NetBeansProjects/test.com.au] and the project path on the webserver. /home/ali/sites/test.com.au

Fix: In Netbeans click on your project > properties > Run Configuration > Advanced > Just put the appropriate server path and equivalent project path. It will work fine.




回答4:


Same problem was solved by commenting xdebug.extended_info = 0. Also one may switch it to 1.



来源:https://stackoverflow.com/questions/14629975/xdebug-in-netbeans-not-stopping-on-breakpoint-inside-file-in-web-roots-paren

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!