New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for command line debugging? #3
Comments
Before you run your script on command line, you need to set an Environment Variable with the IDE key to initiate a debugging session. Windows
UNIX
Make sure you have Xdebug properly configured in both your php.ini, the one for Apache and CLI, that way you avoid any unexpected behaviour when debugging. With SublimeTextXdebug you can add/remove breakpoints, another way is to set the breakpoint in your PHP code with the following function |
yeah i did that. no dice. does this work for you? |
Yeah it worked for me, but I ran the PHP script on the same system (Windows) as Sublime Text. What is your environment?
|
Have a MacOSX 10.8 machine with a Ubuntu 12.04 VM running as a local dev web server. Using ST2. I've tried running the script both on MacOSX and Ubuntu and have set XDEBUG_CONFIG="idekey=sublime.xdebug" on both. I have managed to get this to work using MacDGBp which is a rather old XDEBUG client. |
What does your project.sublime-project file look like for CLI debugging? Is there anything special that needs to be done there? |
Can you post your Xdebug configuration from the *.ini in What is the absolute path of your PHP CLI script on Ubuntu and on OS X? I don't have any settings configured in *.sublime-project, but I think you will need to configure the path_mapping entry in your *.sublime-project. |
Sure. I can get xdebug to work fine when debugging a website in ST2 and also CLI debugging with another app. Using nginx (php5-fpm) instead of apache but both have the same settings for xdebug: zend_extension=/usr/lib/php5/20090626/xdebug.so path on ubuntu is /usr/share/drush/drush.php, mac is /home/vagrant/kalabox/drush/drush.php. this is a little funky since you actually run "drush COMMAND" instead of directly calling drush.php but "drush" is just a bin/bash/bat wrapper for drush.php. I've gotten "drush COMMAND" to work with xdebug using macDGBp. That all said ive also tried with a very simple test script and also no dice. I've got the appropriate path mapping in its *.sublime-project. |
When reproducing this issue on a desktop running Ubuntu 12.10 and on a virtual machine running Ubuntu 13.04, I was able to debug drush from both machines in Sublime Text located on Windows 7. What I experienced as an issue when trying to debug drush was that when I defined the XDEBUG_CONFIG environment variable as normal user, then ran drush as root through This is what did when I wanted to debug drush. # Switch to root user, to make sure the environment variables will be set for root
sudo su
# Set idekey to initialize session and host where to connect session
export XDEBUG_CONFIG="remote_host=host.kala idekey=sublime.xdebug"
# Check if configuration is succesfully configured
php --ri Xdebug
# Start debugging
drush To verify if the debugging session was succesful you should see the following text in your log file which is configured in remote_log. I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: host.kala:9000. :-|
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///usr/share/php/drush/drush.php" language="PHP" protocol_version="1.0" appid="10574" idekey="sublime.xdebug"><engine version="2.2.3"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2013 by Derick Rethans]]></copyright></init> Below are the settings I configured on both machines. /etc/hosts 127.0.0.1 localhost
127.0.1.1 ubuntu
# Mapped IP address of Windows 7 machine to host.kala (similar to your OS X)
172.22.60.8 host.kala /etc/php5/cli/php.ini [xdebug]
zend_extension=/usr/lib/php5/20100525+lfs/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = req
xdebug.remote_connect_back = 1
xdebug.remote_log = "/tmp/xdebug_cli.log" Does your .sublime-project look something like this? {
"ide_key": "sublime.xdebug",
"path_mapping": {
"/usr/share/drush/" : "/home/vagrant/kalabox/drush/"
},
"port": 9000
} Note: You sure the path to drush on Ubuntu is not /usr/share/php/drush/? |
Thanks @martomo! very helpful. i'll give it a shot and see if i can get it to work. will report back as soon as i try it out, hopefully sometime friday. definitey /usr/share/drush... using a custom build https://github.com/kalamuna/kalastack |
@pirog did you manage to get the command line debugging to work? |
I will close this issue as I've been able to debug command line without any issues and I think the above comment should help with which steps to undertake when debugging a command line script (drush). |
@martomo sorry for the delay here but yes i was able to get this to work as expected. not sure what was happening before... |
Sorry to comment on an old issue, but was there anything specific that was causing this? I seem to have the same problem. I can debug through a browser just fine, but triggering any PHP script through the CLI does not work. I'm debugging remotely from OSX to a Vagrant box running CentOS 6.5. |
Hey there,
Great plugin!
I'm trying to debug a command line utility called drush... which is a php based shell for drupal.
Generally it is invoked on the command line. Is there anyway i could use this plugin to debug? I've tried playing around with the sublime settings and settings some environmental variables in the terminal as per http://stackoverflow.com/questions/1947395/how-can-i-debug-a-php-cli-script-with-xdebug but havent been able to get anything.
The text was updated successfully, but these errors were encountered: