PHP learning-use XDebug (Ubuntu) in sublime ). PHP learning-XDebug (Ubuntu) is used in sublime. since SublimeText was used, PHP code has never been debugged, recently I set up the debug environment for PHP learning-using XDebug (Ubuntu) in sublime)
I am ashamed to say that since I started using Sublime Text, I have never debug PHP code. I recently set up the debug environment and record it here.
Install XDebug
Sudo apt-get install php5-xdebug
Edit the xdebug. ini file and add the following configuration:
Xdebug. remote_enable = 1
Xdebug. remote_handler = dbgp
Xdebug. remote_host = 127.0.0.1
Xdebug. remote_port = 9000
Xdebug. remote_log = "/var/log/xdebug. log"
Restart nginx
Sudo/etc/init. d/nginx restart
In Sublime Text, use package control to Install xdebug client, press ctrl + shift + p to bring up the search box, enter Package Control: Select Package Control: Install Package, and enter Xdebug client, find the xdebug client and install it. after installation, restart Sublime. The procedure is as follows:
To debug a project, you must first save the project as a project under sublime.
Sublime-> project-> save project...
Configure the project
Sublime-> project-> edit poject
The configuration file is similar to the following:
{
"Folders ":
[
{
"Follow_symlinks": true,
"Path ":"."
}
],
"Settings ":{
"Xdebug ":{
"Url": "http://my.local.website /",
}
}
}
Then install the chrome Xdebug Helper extension in Chrome. After downloading and installing Chrome extensions, you must restart your browser. After restarting, you will see the new icon in the address bar of Chrome:
Click it to enable/disable debugging. However, we first need to adjust the session key that uses Sublime Text in the extension.
In Chrome, Tools> Extensions
Open Xdebug helper options:
Enabling debugging is also relatively simple. right-click the place where you want to add a breakpoint
Xdebug-> Add/Remove breakpoint
In this way, the project will stop when it is running to the bank.
Start Debugging and select
Tools-> xdebug-> start debugging (launch browser)
Sublime will automatically open the browser and enter the link of the website written during configuration for debugging.
You can right-click the functions used in debugging in the debugging file to view them.
The shortcut keys are described as follows:
Start/Stop debugging session
Start Debugging-Ctrl + Shift + F9 or lower + Shift + F9
Start Debugging (Launch Browser)
Restart Session
Stop Debugging-Ctrl + Shift + F10 or convert + Shift + F10
Stop Debugging (Launch Browser)
Stop Debugging (Close Windows)
Breakpoints
Add/Remove Breakpoint-Ctrl + F8 or combine + 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
Evaluate
Execute
Status
Continuation commands
Run-Ctrl + Shift + F5 or values + Shift + F5
Run To Line
Step Over-Ctrl + Shift + F6 or above + Shift + F6
Step Into-Ctrl + Shift + F7 or Shift + F7
Step Out-Ctrl + Shift + F8 or milliseconds + Shift + F8
Stop
Detach
Other
Restore Layout/Close Windows-Ctrl + Shift + F11 or release + Shift + F11
Settings-Default
Settings-User
Unable to track breakpoints due to issues
This may be because the xdebug port is occupied. press Ctrl + 'or the menu bar View-> show Console to View the error message. it may be because the xdebug port is occupied.
Disable debugging in sublime xdebug or restart sublime to solve this problem. if not, you can modify the port number, such as xdebug. change the port number in ini to 1000 and add the following content to the perferences-> package settings-> xdebug-> setting-user file:
{
Port: 10000
}
Ghost (Ubuntu) was ashamed to say that since Sublime Text was used, PHP code has never been debugged. recently, the debug environment has been set up...