foreword
Recently uninstalled IDEA
, because there is no activation code...
So I replaced Visual Studio
and Xamarin
used C#
the development Android
application, but IDEA
uninstalled, so naturally it can't be IDEA
used to debug my PHP
page, so I have to Visual Studio Code
use it to debug the PHP page I wrote.
Install the XDebug plugin
Get PHP version information
Different versions PHP
correspond to different XDebug
versions. If the version is wrong, I don’t know what will happen. Anyway, just download according to your own version!
Let’s PHP
output phpinfo()
the information now, check the two values of sum Architecture
and what I show here is sum , and record these two values and your own version.Zend Extension Build
X64
API320190902,TS,VC15
PHP
Download the corresponding XDebug plugin
Download address: The plug-in download address
can be seen from the picture, x64
corresponding to the download 64-bit
version, PHP
the version must be corresponding, and then Zend Extension Build
remember to see if there TS
is a corresponding VC
version, and then we can download it.
Windows
The system can be downloaded directly here dll
, if it is, linux
please download and compile it yourself.
plugin installation
Under normal circumstances, the downloaded dll
files will be placed in the corresponding PHP
extension directory, that is, the PHP
corresponding ext
folder.
Of course, you can leave it alone, because you must write the complete path when configuring the configuration XDebug
of the module . Personally, I am more disciplined, so I put the files in the extension directory.zend_extension
dll
PHP
Profile settings
Once the plugin is in the folder, we need to configure the module settings php.ini
of the file XDebug
.
I will give my configuration below, but the complete XDebug configuration is far more than these parameters. If you need to modify other settings by yourself, you can Baidu.
Here, please pay attention to xdebug.remote_port=9000
the statement of port number. This sentence corresponds to XDebug
the port number, so please be sure to remember your own custom port number. The port number I defined here is 9000.
;xdebug支持
[xdebug]
zend_extension ="安装PHP的根目录/ext/php_xdebug-2.9.2-7.4-vc15-x86_64.dll"
xdebug.remote_enable = On
xdebug.remote_autostart = On
;启用性能检测分析
xdebug.profiler_enable = On
;启用代码自动跟踪
xdebug.auto_trace=On
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name = cachegrind.out.%t.%p
;指定性能分析文件的存放目录
xdebug.profiler_output_dir ="安装PHP的根目录/tmp"
xdebug.show_local_vars=0
;配置端口和监听的域名
xdebug.remote_port= 9000
xdebug.remote_host="localhost"
Check whether the configuration takes effect
Restarting your own environment, LNMP
or other environments, will not solve all problems just by restarting.
Then we print out phpinfo()
the information again, if the relevant information appears, XDebug
it means that the installation is successful, otherwise check XDebug
whether the installation is successful.
PHP Debug for VS Code
Follow the above steps to get it done, and then install VS Code
the PHP Debug
plugin.
Then come to the debugging page and make corresponding launch.json
settings. Here, remember that the port number should correspond to XDebug
the port number in the above settings. My side is 9000, which corresponds to the above.
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
breakpoint debugging
At this point, write your own PHP page for testing. Remember to test the breakpoint under the root directory of the server web page, otherwise it will be useless.
If there is something wrong, please criticize and correct.