简体   繁体   中英

Xdebug with Sublime Text 2

I'm trying to set up Xdebug with Sublime Text 2 to debug PHP on my local machine but am getting absolutely nowhere. I'm running MAMP with PHP 5.4. I have this entered this at the end of my php.ini:

[xdebug]
zend_extension="/Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_autostart=1

The Xdebug.so extension comes with MAMP and I have verified that it is in the location specified in the php.ini file. I can see Xdebug info in my PHP info.

In Sublime Text 2, I have installed this package and changed the settings in my project to this:

{
    "folders":
    [
        {
            "path": "/Applications/MAMP/htdocs"
        }
    ],

    "settings": {
        "xdebug": { "url": "http://localhost" }
    }
}

I can press SHIFT and F8 to bring up the menu for the plugin in Sublime Text 2, and can add or remove breakpoints (a grey dot appears on the left side of the line of code). When I hit "Start Debugging", it opens up a browser with the "?XDEBUG_SESSION_START=sublime.xdebug" string appended to the url. But my breakpoints don't do anything.

I've tried adding xdebug_break(); into my code to see if that would stop the program, but it doesn't. The browser and the IDE just don't seem to be connected at all...

Any ideas?

First thing, that Kindari's xdebug plugin just isn't something you're going to be happy about. He made that plugin sort of as a trial, learning sublime api while writing it, so it's full of issues, hardcoded variables and stuff. I finaly gave up on it and uninstalled that plugin, it just wasn't useful(but it worked). One of biggest flaws IMHO, was the inability to show array variables more than 1 level deep. He posted on github that he's going to rewrite it from scratch, couple months ago, and since then it seems abandoned, but I am still desperately waiting for new version to come out, I was even thinking about learning python and writing it myself.

Well, if you wan't to try it, first make sure Xdebug works, by trying it with some other Xdebug client. If Xdebug works elsewhere, make sure you have python2.6 installed, since it doesn't work with 2.7. If you are running ubuntu 12.04, python2.6 is not in repositories, so there's workaround for Ubuntu 12.04 from plugin readme:

  1. Download [http://packages.ubuntu.com/lucid/python2.6][python 2.6].
  2. Extract it:

     dpkg-deb -x python2.6_2.6.5-1ubuntu6_i386.deb python2.6 
  3. Copy the extracted usr/lib/python2.6 folder to {Sublime Text directory}/lib (=/usr/lib/sublime-text-2/lib/)

Remember two things: First, there is a file /usr/lib/sublime-text-2/lib/python26.zip, so do NOT delete this file. And second, in that .deb you extracted, there's usr/lib/python2.6 in it, that's what you want to copy, not the whole python2.6 directory. So, if you are outside of that unpacked .deb,

cp -r python2.6/usr/lib/python2.6 /usr/lib/sublime-text-2/lib

might do the job. I am not really sure here, if you're supposed to copy that python2.6/usr/lib/python2.6 folder or just it's content, I did copy both and it didn't screw anything up.

Are you install python version 2x? Try to install python, or set xdebug.remote_enable=1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM