1

I'm trying to configure Xdebug to work with Sublime Text 3 but I can't get anything to show in the Context, Watch or Stack tabs e.g. by setting a breakpoint and clicking Start Debugging (Launch Browser). The browser opens the index.php file with ?XDEBUG_SESSION_START=sublime.xdebug appended to the url but execution of the code does not stop when the breakpoint is reached.

I've also tried adding xdebug_break() to index.php to no effect.

From what I've read, specifying path_mapping in the .sublime-project file seems the most likely solution. The documentation states that:

path_mapping

For remote debugging to resolve the file locations it is required to configure the path mapping with the server path as key and local path as value.

I'm using IIS on Windows 10 so the app's files are stored in C:\inetpub\wwwroot\ and the homepage's url is http://localhost/index.php which I'm assuming are the server path and local path respectively and as such the .sublime-project file looks like this:

{
    "folders":
    [
        {
            "path": "."
        }
    ],
    "settings": {
        "xdebug": {
            "url": "http://localhost/index.php",
            "path_mapping" : {"C:\\inetpub\\wwwroot\\" : "http://localhost/index.php"}
        }
    }
}

Is this correct? If it is, is my php.ini file configured correctly?

[ExtensionList]
.
.
.
zend_extension = "C:\Program Files (x86)\PHP\php-5.6.30-nts-Win32-VC11-x86\ext\php_xdebug-2.5.1-5.6-vc11-nts.dll"

[XDEBUG]
xdebug.default_enable=1
xdebug.remote_autostart=0
xdebug.remote_connect_back=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_host=localhost
Community
  • 1
  • 1
gbavba
  • 116
  • 2
  • 9
  • 1
    *"which I'm assuming are the server path and local path respectively"* NO -- it has nothing to do with URL. Path mappings needs to be used when remote **file path** does not match local one, e.g. on local computer website's `index.php` is located in `/var/www/` but on remote it's in `/var/www/html/site-name/`. Collect xdebug logs to see what's happening. – LazyOne Mar 17 '17 at 09:16
  • Thank you kindly @LazyOne problem now solved with the help of your comment. – gbavba Mar 22 '17 at 10:49

1 Answers1

0

The path_mapping and php.ini settings were both incorrect.

Based on @LazyOne's comment, removed the incorrect path_mapping in the .sublime-project file so it now looks like this:

{
    "folders":
    [
        {
            "path": "."
        }
    ],
    "settings": {
        "xdebug": {
            "url": "http://localhost/index.php"
        }
    }
}

Then added xdebug.remote_log="C:\Windows\Temp\Xdebug\remote.log" to php.ini and inspecting the log showed:

I: Remote address found, connecting to ::1:9000.
E: Time-out connecting to client. :-(

Searching this error lead to @Axel's answer to this SO question and based on this, changed xdebug.remote_connect_back=1 to xdebug.remote_connect_back=0 in php.ini

Breakpoints then started working and the Context, Watch and Stack tabs started showing the relevant data on reaching them.

Community
  • 1
  • 1
gbavba
  • 116
  • 2
  • 9
  • So the issue was that xdebug support in Sublime does not support IPv6 .. so it must be IPv4? How does the successful session looks in the xdebug log? I mean -- what IP:port it is able to connect to? – LazyOne Mar 22 '17 at 10:59
  • `localhost:9000` log shows `I: Connecting to configured address/port: localhost:9000.` then `I: Connected to client. :-)` – gbavba Mar 22 '17 at 11:17