Ashamed to say, since the beginning of the use of sublime text, never debug PHP code, recently set the debug environment, here to record.
Installing Xdebug
sudo apt-get install Php5-xdebug
Edit the Xdebug.ini file and add the following configuration
xdebug.remote_enable=1xdebug.remote_handler=dbgpxdebug.remote_host=127.0.0.1xdebug.remote_port= 9000xdebug.remote_log= "/var/log/xdebug/xdebug.log"
Re-start Nginx
Sudo/etc/init.d/nginx restart
Then, in sublime text, use the package control installation to xdebug client,
bring up the search box with Ctrl+shift+p, and enter the control: Select which of the package Control:install Enter Xdebug client, locate Xdebug client, install, reboot sublime after installation is complete. It operates as follows:
To debug a project, you first need to save the project under Sublime as a program.
Sublime->project->save Project as ...
Next configuration item
Sublime->project->edit Poject
The configuration file resembles the following:
{" folders": [ { "follow_symlinks": True, "path": "." } ], "settings": { " Xdebug ": { " url ":" http://my.local.website/", }} }
Then install the Chrome Xdebug Helper extension in Chrome. After you download and install the Chrome extension, you must restart the browser. After restarting, you will see a new icon in the Address bar of Chrome:
Click on it to enable/disable debugging. However, we first need to adjust the session key using Sublime Text in the extension.
Tools > Extensions in Chrome
Open the Xdebug helper options:
Debugging mode is also relatively simple, where you want to add a breakpoint right-click
Xdebug->add/remove Breakpoint
So the project will stop when it runs to the bank.
Then start debugging, and in the menu bar select
Tools->xdebug->start Debugging (Launch browser)
Sublime will automatically open the browser, enter the configuration to write the site link, for debugging.
The features used in debugging can be viewed in the debug file by right-clicking.
The shortcut keys are described below
Start/stop Debugging session
- Start Debugging- Ctrl+Shift+F9 or?+Shift+F9
- Start Debugging (Launch Browser)
- Restart Session
- Stop Debugging- Ctrl+Shift+F10 or?+Shift+F10
- Stop Debugging (Launch Browser)
- Stop Debugging (Close Windows)
Breakpoints
- Add/remove Breakpoint- Ctrl+F8 or?+F8
- Set Conditional Breakpoint-Shift+F8
- Clear Breakpoints
- Clear All Breakpoints
Watch expressions
- Set Watch Expression
- Edit Watch Expression
- Remove Watch Expression
- Clear Watch Expressions
Session commands
Continuation commands
- Run- Ctrl+Shift+F5 or?+Shift+F5
- Run To Line
- Step over- Ctrl+Shift+F6 or?+Shift+F6
- Step into- Ctrl+Shift+F7 or?+Shift+F7
- Step out- Ctrl+Shift+F8 or?+Shift+F8
- Stop
- Detach
Other
- Restore layout/close Windows- Ctrl+Shift+F11 or?+Shift+F11
- Settings-default
- Settings-user
Problem cannot track breakpoints
This may be the Xdebug port is occupied, press CTRL + ' or the menu bar View->show console to view the error message, it is possible that the Xdebug port has been occupied for the sake of.
Turn off debugging in sublime Xdebug, or restart sublime to resolve this problem, if not, you can modify the port number, such as the port number in Xdebug.ini is modified to 1000, in Perferences->package The Settings->xdebug->setting-user file includes the following:
{ "port": 10000}
It's still a bit of time to fix this.
Reference
Debug PHP with Sublime Text 2 and Xdebug on Ubuntu
Debug PHP code with Xdebug and sublime
Sublime Configuration Xdebug
PHP Learning-using Xdebug (Ubuntu) in sublime