Xdebug debugger client integration for Sublime Text.
Based on the Xdebug protocol functionality in SublimeXdebug package by Kindari.
- Remote debugging by configuring path mapping
- Navigate on breakpoint hit to relevant file on specific line, when found on local drive
- Overview of breakpoints in all files and disable/enable breakpoints with simple click
- Debugging layout for stack history and context variables with syntax
- Evaluate a given string within the current execution context
- Inspect (nested) context variables
- Set conditional breakpoints
- Works on both Sublime Text 2 and 3
- Show global/class context variables
- Option for defining debug layout in settings
Here is a complete list of commands you can find Command Pallette under the Xdebug
namespace or in the menu under Tools / Xdebug
:
- Start Debugging - Ctrl+Shift+F9
- Start Debugging (Launch Browser)
- Stop Debugging - Ctrl+Shift+F10
- Stop Debugging (Launch Browser)
- Stop Debugging (Close Windows)
Launch Browser menu option will only show if you have an url configured within settings.
- Add/Remove Breakpoint - Ctrl+F8
- Set Conditional Breakpoint - Ctrl+F9
- Clear All Breakpoints
- Evaluate
- Execute
- Status
- Run - Ctrl+Shift+F5
- Step Over - Ctrl+Shift+F6
- Step Into - Ctrl+Shift+F7
- Step Out - Ctrl+Shift+F8
- Stop
- Detach
- Reset Layout - Ctrl+Shift+F11
- Settings
Settings will show current user settings, when none available it will generate a template.
Execute "Package Control: Install Package" in the Command Pallette to retrieve a list of available packages.
Search in the list and install package Xdebug Client
.
Clone the repository by executing the following command in your Packages directory:
git clone https://github.com/martomo/SublimeTextXdebug.git "Xdebug Client"
Get the latest source from GitHub and extract the source into your Packages directory.
Note: You can locate your Packages directory in the menu under Preferences / Browse Packages...
In order to be able to debug your PHP scripts, you will need have Xdebug extension installed on your server. See here for installation instructions
Below is a configuration template for php.ini/xdebug.ini, be warned if you are on a Live environment, remote_connect_back allows every debug request from any source to be accepted.
[xdebug]
zend_extension = /absolute/path/to/your/xdebug-extension.so
;zend_extension = "C:\Program Files (x86)\PHP\ext\php_xdebug.dll"
xdebug.remote_enable = 1
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = 9000
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = req
xdebug.remote_connect_back = 1
For details about all available settings for configuring Xdebug, see here.
The following settings can be configured in Xdebug.sublime-settings or in *.sublime-project files:
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.
ide_key
An IDE key is used to identify with debugger engine when Sublime Text will start or stop a debugging session.
This package does not filter sessions by IDE key, it will accept any IDE key, also ones that do not match this configured IDE key. It is merely used when launching the default web browser with the configured URL.
url
Determine which URL to launch in the default web browser when starting/stopping a session.
port
Which port number Sublime Text should listen to connect with debugger engine.
close_on_stop
Always close debug windows and restore layout on session stop.
max_children
Maximum amount of array children and object's properties to return.
max_depth
Maximum amount of nested levels to retrieve of array elements and object properties.
debug
Show detailed log information about communication between debugger engine and Sublime Text.
Below are examples how to configure your Xdebug.sublime-settings and *.sublime-project files.
Xdebug.sublime-settings
{
"path_mapping": {
"/absolute/path/to/file/on/server" : "/absolute/path/to/file/on/computer",
"/var/www/htdocs/example/" : "C:/git/websites/example/"
},
"ide_key": "sublime.xdebug",
"url": "http://your.web.server",
"port": 9000,
"close_on_stop": true,
"max_depth": 3,
"max_children": 32,
"debug": true
}
*.sublime-project
{
"folders":
[
{
"path": "..."
}
],
"settings":
{
"xdebug": {
"path_mapping": {
"/absolute/path/to/file/on/server" : "/absolute/path/to/file/on/computer",
"/var/www/htdocs/example/" : "C:/git/websites/example/"
},
"ide_key": "sublime.xdebug",
"url": "http://your.web.server",
"port": 9000,
"close_on_stop": true,
"max_depth": 3,
"max_children": 32,
"debug": true
}
}
}
Can I have both SublimeTextXdebug and SublimeXdebug installed?
No. Having installed both packages can cause conflicts, because they might both listen to the same port for a debugger engine response and have similar keymapping.
However (project) settings from SublimeXdebug are compatible with SublimeTextXdebug.
SublimeTextXdebug can start or stop a debugging session by launching the default web browser with the configured URL and parameter XDEBUG_SESSION_START
or XDEBUG_SESSION_STOP
which uses the configured IDE key as value. By default the IDE key is sublime.xdebug
.
If you do not configure the URL, the plugin will still listen for debugging connections from Xdebug, but you will need to trigger Xdebug for a remote session.
- With SublimeTextXdebug you can add/remove breakpoints, which are send on session start.
- Another way is to set the breakpoint in your PHP code with the following function
xdebug_break()
.
SublimeTextXdebug is released under the MIT License.