Xdebug (Vagrant) not working with SublimeText 3

2019-07-20 06:29发布

问题:

I've installed Xdebug on my Vagrant server and the XdebugClient plugin for Sublime Text 3. When I start debugging, my page loads in the browser but nothing shows up in the context, watch or stack tabs. The xdebug.log file is also empty. The following are my settings:

php.ini

[CUSTOM]

error_reporting=1
display_errors=true
track_errors=1

[xdebug ]

zend_extension="/usr/lib/php5/20121212/xdebug.so"
xdebug.remote_connect_back=1
xdebug.default_enable=1
xdebug.remote_autostart=0
xdebug.idekey=sublime.xdebug
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=10.0.2.15
xdebug.remote_port=9001
xdebug.remote_log="/var/log/xdebug/xdebug.log"
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/tmp/profiler"
xdebug.remote_mode=req

xdebug.ini

zend_extension="/usr/lib/php5/20121212/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=10.0.2.15
xdebug.remote_port=9001
xdebug.remote_log="/var/log/xdebug/xdebug.log"

.sublime_project

"settings": {
        "xdebug": {
            "url": "http://mysite.dev/",
            "path_mapping": {"/vagrant/www/mysite/dist" : "/Users/iii/Documents/Dev/vagrant/www/mysite/dist"},
            "super_globals": true,
            "close_on_stop": true,
        }
    }

Xdebug.sublime-settings

{
    "close_on_stop": true,
    "pretty_output": true,
    "launch_browser": true,
    "debug": true,
    "ide_key": "sublime.xdebug",
    "port": 9001,
}

Can someone please tell me what is wrong here?

回答1:

I was facing a similar problem with Vagrant/Sublime/Xdebug. I found that the latest version of Xdebug (2.6.0) doesn't work well with Sublime. Evidently, there's an XML formatting issue.

I found two things that both solved the problem:

  • Revert to Xdebug 2.5.5, or
  • set "super_globals": false, in your config.

(https://github.com/martomo/SublimeTextXdebug/issues/172)


ETA 24 Oct 2018:

In my case, the solutions above were not necessarily a fix, but just helped to avoid the real issue in some cases. The real fix appears to require a change to the Sublime Package: https://github.com/martomo/SublimeTextXdebug/issues/172#issuecomment-410478057

I ended up forking the SublimeTextXdebug (assuming this is the package you're using), patching it, and then replacing the package with the patched version. (There's a pull request in the main repository, but I don't think it's been pulled yet.)



回答2:

Just in case someone else has the same problem. I was using Sublime 2 with Xdebug without any issues. I upgraded to Sublime 3 and was not able to get Xdebug to break. I went through various posts and tried various recommendations without success, until, I added the setting xdebug.remote_log="/var/log/xdebug/xdebug.log". No idea why, but once this was added, it started to work.