45

I'm having a problem with xdebug not stopping at breakpoints when using remote debugging (everything is fine when running scripts via the command line). It will break at the first line of the program, then exit, not catching any breakpoints.

It used to work fine, until I switched over to using MacPorts for Apache and PHP. I've tried re-compiling it several times (with several versions), but no dice.

I'm using PHP 5.3.1 and Xdebug 2.1.0-beta3

I've also tried at least 3 different debugging programs (MacGDBp, Netbeans and JetBrains Web IDE).

My php.ini settings look like:

[xdebug]
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.remote_host=localhost
xdebug.idekey=webide

And when I log the debugger output, setting a breakpoint looks like this/;

<- breakpoint_set -i 895 -t line -f file:///Users/WM_imac/Sites/wm/debug_test.php -n 13 -s enabled -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="895" state="enabled" id="890660002"></response>

When run, the debugger will get the context of the first line of the application, then send the detach and stop messages.

However, this line is output when starting the debugger.

<- feature_get -i 885 -n breakpoint_types -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_get" transaction_id="885" feature_name="breakpoint_types" supported="1"><![CDATA[line conditional call return exception]]></response>

Does 'line conditional call return exception' mean anything?

6
  • Further research reveals that 'line conditional call return exception' is a list of supported breakpoints, not any sort of error message.
    – Bryan M.
    Mar 2, 2010 at 1:08
  • 3
    calling xdebug_break(); in my code will properly cause the debugger to stop.
    – Bryan M.
    Mar 3, 2010 at 17:08
  • Can you specify the path to your php.ini file. Are you using HTTPS for this host?
    – DrDol
    Aug 8, 2010 at 22:07
  • Using regular http, with ini file at /opt/local/etc/php5/php.ini (default location for MacPorts install)
    – Bryan M.
    Aug 9, 2010 at 12:30
  • After having this problem a very long time, it seems to have been resolved by a) upgrading from Leopard to Snow Leopard (which reinstalls much of the unix system in OS X) and b) completely re-installing my dev environment via MacPorts.
    – Bryan M.
    Jan 8, 2011 at 15:51

24 Answers 24

36

I had this problem and took me ages to find the answer.

In your debug config, in the server area, click Configure, go to Path Mapping, click the path that's there and click edit, change to Path in file system and navigate to the correct file.

Done.

5
  • That worked for me too. Apparently, my previous, though not wrong Path mapping was relative to a linked folder. (Feels like a bug to me.)
    – e-motiv
    Nov 26, 2012 at 13:26
  • I ran into this as well - the top voted solution worked but presumably the UI has changed ? I did Preference/Paths and then set both the Local and Remote path to the same project directory and it starting work on breakpoints in the Test file. Presumably related to how PHPUnit runs the actual test (starting a new process?).
    – brez
    Oct 9, 2013 at 21:42
  • Just bare in mind you need to specify path on the server filesystem rather than web url so for instance: /var/www/html needs to be maped to C:\myworkspace\projectx etc
    – JJ Roman
    Jul 7, 2015 at 9:04
  • For me, the problem was that Server Path was set to ~/Code/mysite, and I guess the ~ isn't honored, so I needed to change it to /home/vagrant/Code/mysite. This took me days to figure out. Ugh.
    – Ryan
    Jul 24, 2017 at 0:20
  • Watch out for symlinks, too! If you are using PHP links in the apache directory, xdebug will resolve the link and will refer to the linked file instead of the link. So, even if you set up an Apache directive to /var/www/my_php/linkedFile.php, if that link resolves to /tmp/src/linkedFile.php for some reason, you should set up your path mapping to /tmp/src and not /var/www/my_php
    – Larry B.
    Nov 28, 2018 at 23:28
23

I had the same problem, and finally I found that my php.ini was missing these two important settings:

xdebug.remote_autostart = "On"
xdebug.remote_enable = "On"

Then it worked perfectly.

2
  • This worked great, remember to restart apache after changing. The _autostart flag was it for me.
    – Bradley
    Mar 14, 2014 at 7:58
  • 1
    xdebug.mode = debug xdebug.start_with_request=yes in Xdebug 3
    – frazras
    Mar 5, 2021 at 17:43
8

XDebug works fine in my Ubuntu Lucid box using NetBeans, and i do have the zend_extension line in my php.ini (/etc/php5/apache2/php.ini).

I'm using netbeans 6.9 and PHP 5.2 with xdebug 2.0.4-2

I'm pasting the relevant lines here, hope it helps:

zend_extension=/usr/lib/php5/20060613/xdebug.so

[debug]
; Remote settings
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey="netbeans-xdebug"

; General
xdebug.auto_trace=off
xdebug.collect_includes=on
xdebug.collect_params=off
xdebug.collect_return=off
xdebug.default_enable=on
xdebug.extended_info=1
xdebug.manual_url=http://www.php.net
xdebug.show_local_vars=1
xdebug.show_mem_delta=0
xdebug.max_nesting_level=100
;xdebug.idekey=

; Trace options
xdebug.trace_format=0
xdebug.trace_output_dir=/tmp
xdebug.trace_options=0
xdebug.trace_output_name=crc32

; Profiling
xdebug.profiler_append=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name=crc32
1
  • Beware the profiler, I had a system slow down terribly and then crash due to filling up the disk with huge files in /tmp, iut was cuased by the XDEBUG profiler...
    – pgr
    Apr 17, 2016 at 10:49
8

from http://xdebug.org/docs/install , "You should ignore any prompts to add "extension=xdebug.so" to php.ini — this will cause problems."

so, this fixed it for me :

in the config file , where you load the xdebug extension ( for me , for the CLI version of php , that was /etc/php5/cli/conf.d/xdebug.ini ) - dont specify

extension=xdebug.so

instead , use

zend_extension=/path/to/xdebug/module/xdebug.so

( for me , this was something like /usr/lib/php5/(...)/xdebug.so )

Use locate xdebug.so to find the location.

5
  • 2
    I already am using zend_extension. Thanks for the insight, though.
    – Bryan M.
    Mar 12, 2010 at 15:35
  • Are you sure there isn't an extension=xdebug.so somewhere in the PHP configuration? I had both extension=xdebug.so and zend_extension=/path/to/xdebug.so and for some reason it was taking extension=xdebug.so, which loads the extension, but breakpoints don't work.
    – mjs
    Jul 20, 2010 at 21:57
  • I double checked. Only using zend_extenstion. Again, the problem here is with breakpoints when running through a web browser. Everything works normally with CLI scripts or PHPUnit.
    – Bryan M.
    Jul 21, 2010 at 13:59
  • I'm sure it is just a typo on SO, but check the spelling of "zend_extension" in the PHP file - it would be a shame it that was the cause. Aug 29, 2010 at 18:19
  • I hope showing this contradiction helps. serverfault.com/questions/202959/… Nov 17, 2010 at 15:14
7

I have had the same issue, the solution for me was to have the local code on the same path as the remote code.

Example

On the webserver the code was located on the path: /var/www/dev01/app_name

Locally the code was located in my home directory: /home/me/projects/app_name

This configuration caused my IDE (Eclipse and Komodo) to fly straight past the breakpoints.

Changing the local path from /home/me/projects/app_name to /var/www/dev01/app_name fixed the issue. Using sshfs to locally mount the remote filesystem makes it even easier.

2
  • looks like I am experiencing same problem. In call stack I can see reference to file location on remote server. My problem thought is ... I am trying to debug on windows my code running on Linux. Is there any generic solution?
    – JJ Roman
    Jul 7, 2015 at 8:31
  • @JJRoman I have not tried it in a mixed environment. Perhaps the "Path Mapping" answer from pitchandtone will work for you.
    – safl
    Jul 8, 2015 at 8:51
4

I just experienced something similar to safl's comment above using Komodo but not sure if it's related:

I had xdebug set up using zend_extension with Komodo and it works perfectly, can set breakpoints and xdebug_break(), but only some files. Others did not work.

The solution was in the way that the mapping of the remote and local paths occurred. Turns out that Komodo is doing a case-sensitive compare on path name, so my mapping didn't quite match. Files that the debugger opened from stepping through were on the right path, but files that I opened through the ide had an uppercase driveletter which apparently caused Komodo to overlook.

3

I tried all these solutions to no avail. I was confused because XDebug worked for one of my projects but not this new one. After stumbling around comparing configuration properties, I realized that on

Project Properties > Sources > Web root:

the value was set to a default value on the new project, but set to webroot on the existing project. So, I browsed to the project's webroot and set that value. I tested it and, bada-bing, it worked.

enter image description here

1
  • Thanks for this! The web root definition fix the exact same problem for me.
    – Steven
    Aug 10, 2012 at 11:52
2

Are you totally sure you're not loading the Xdebug via extension=xdebug.so? Xdebug will load if this line appears in your php.ini (i.e. it appears in phpinfo() output, etc.) but breakpoints do not work if loaded in this way. (It will even connect to debugger clients, and accept breakpoints--they just never get triggered.)

I suggest you comment out the zend_extension line and see if it's still loaded--you might think you're loading Xdebug via /etc/php5/conf.d/xdebug.ini, for example, but something has added it to /etc/php5/apache2/php.ini behind your back.

See this question & answer for more information.

0
2

I ran into this same exact thing and was banging my head against it for a while. At some point I had also added ZendDebugger.so to my PHP.ini and that was what was breaking Xdebug. Commenting out the ZendDebugger.so line in my php.ini fixed it.

If you're not using ZendDebugger, you might just start disabling other Zend extensions and see if it's another extension causing the conflict.

2

I use Eclipse and also looked for a while. All things in php.ini have been right.

At the end, I found out, that in Eclipse the debugger was set so ZEND-Debugger. After I changed it to XDEBUG it worked fine.

Regards Joerg

2

I am also having the same problem. i got the solution that to load the dll file we should use zend_extension.

zend_extension=php_xdebug-2.5.5-5.6-vc11.dll 

Rest configuration will be

xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
0

Could you provide complete session log while trying to debug with Web IDE?

BTW when using Web IDE you typically don't need to set xdebug.idekey=webide since ide key is automatically assigned via url parameter.

2
  • Full log output here: pastie.org/866632. The debugger stopped on the first line, and ignored all other breakpoints.
    – Bryan M.
    Mar 12, 2010 at 15:47
  • Logs show that IDE is trying to put breakpoint to the file '/Users/WM_imac/Sites/wm/debug_test.php'. Does such a file exist, or real debug_test.php has different location?
    – ksafonov
    Mar 24, 2010 at 9:31
0

I hit into that from time to time and have never been able to find out the real cause of the issue.

I usually resolve by,

  1. Placing more breakpoints at the client code constructing the instances and loading the classes (as it seems like XDebug will ignore some breakpoints due to class-loading issues). You can learn and realize where these locations are by doing some step-ins.

  2. Check the source paths of the dependencies. XDebug picks up these files by their full paths, you can see how your IDE addresses them at your breakpoint panel.

0

In my case, the problem was happening in only one project (I was only able to break using xdebug_break), while in the other projects was working fine.

It was fixed editing the file: nbproject/private/private.properties: And set:

copy.src.files=false

When I created the project I selected "copy sources" option by mistake. Then I manually moved the project and edited its source path (at the "nbproject/project.properties" file), which the debugger was still looking for the old path (set in copy.src.target).

So technically, other way to fix this DEBUG problem is to recreate the nbproject directory (by removing it and creating the project again). I guess the debugger should work fine with the "copy" option enabled (as I never use it).

I hope this can help.

0

I had a similar issue and came across a post to fix the problem. My html form (testform.html) was calling a php script (runQuery.php) and Netbeans could not break at the set break points in my runQuery.php

After checking all the configuration settings in php.ini and Netbeans by searching on forums like this one, I discovered that netbeans will only break on the break points if the Index file for the project is a PHP file. This is very important otherwise you will spend hours trying to figure out why break points are not working.

In Netbeans go into the File/Project Properties/Run Configuration and check that the Index file is a PHP file. In my case I changed my index file from testform.html to testform.php and it worked, I was able to break on break points.

0

When it comes to paths, OSX file system is not case sensitive, but xdebug seems to be.

In my case everything seemed to work even though I was running the script using /proj/test.php instead of /Proj/test.php.

When xdebug (or at lest the version I currently have) is checking for breakpoints, the check is case-sensitive. If the break point is set for /Proj/test.php, but the script is run via /proj/test.php then there is no match.

I also had a similar problem with the PHP include path. The path included /proj -directory, which was wrong. Running the code worked, but since the breakpoints were set using /Proj, they were not hit.

To check if this is the problem:

  • Enable logging, -dxdebug.remote_log=/tmp/remote.log
  • Check the exact path in the log when breakpoints are set
  • Compare the path to the PHP intepreter is using, for example: echo dirname(__FILE__) ;
0

There can also be a problem with unusual symbols in the path. For example,I was having my code located by path:

C:\[dev]\OpenServer\domains\...

And I was unable to catch anything, but after changing path problem disappeared:

C:\dev\OpenServer\domains\...

So even brackets matter.

0

I was trying to debug with PhpStorm, but it didn't stop at some breakpoints and started ignoring even more as I was trying every single solution I could find with Google.

The problem was there were multiple detached PHP processes running in the background that actually handled my requests. PhpStorm didn't stop at breakpoints because the process I was debugging wasn't receiving requests. Killing these processes solved it for me.

0

I can't comment on a post therefore this post.

The solution to my problem was a lot like pitchandtone said. Eclipce had made wrong and double path mapping items. Nevertheless I could use the relative paths (i.e. /project/folder).

0

I hate these configurations. My life was changed when I knew the lib Dephpugger.

Is a debugger to run in terminal (like ipdb for Python and byebug for Ruby). https://github.com/tacnoman/dephpugger Is very easy to use.

0

Just for a quick update on the subject I had a similar problem with my new dev setup and it was apparently a version problem : at least with PHP Version 7.1.20-1+ubuntu16.04.1+deb.sury.org+1 xdebug 2.7.1 didn't work :

it performed successfully the first request (I am on a Symfony project so it's router.php) but then when my IDE (PHPSTORM) asked it for another breakpoint it just crashed so no breakpoint log and of course my page didn't load too ^^.

I figured it out watching the log (in php.ini you can customize it with xdebug.remote_log parameter). Hopefully i rollbacked xdebug to 2.6.1 and now all is alright.

Hope it helps someone ;)

0

In my case, when I move the zend_extension item from above [xdebug] to beneath [xdebug], it works well.

;zend_extension = "D:\wamp\bin\php\php5.6.25\ext\php_xdebug-2.5.4-5.6-vc11-
x86_64.dll"
[xdebug]
zend_extension ="D:/wamp/bin/php/php5.6.25/zend_ext/php_xdebug-2.4.1-5.6-vc11.dll"

xdebug.auto_trace = On
xdebug.remote_enable = On
xdebug.remote_autostart = On
xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = On
0

To fix issues debugging PHP CLI,

Add environment variables to ~/.bashrc (and reload it afterwards):

export PHP_IDE_CONFIG="serverName=www.yourservernameurl.com"
export XDEBUG_CONFIG="idekey=PHPSTORM"

(I use phpstorm, but you can omit the second one as needed)

-1

Also make sure that the files are synchronized local and remote, otherwise your breakpoint might land in a invalid area, e.g. empty line and it won't work.

Also make sure that you have enough permissions. I tried to synchronize through NetBeans and got Permission denied

Also make sure that the URL in your browser is set correctly after you start the debugger. My nbproject folder had an old URL in it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.