PHP xdebug3
首先创建一个php文件添加内容
phpinfo()
右击 查看网页源代码,复制整页的代码
打开Xdebug:支持-定制安装说明 --- Xdebug: Support — Tailored Installation Instructions
注意:PHP8.0版本无法使用
粘贴代码后点击按钮获取
下载.dll文件
下载后,重命名文件为 php_xdebug.dll
然后把文件复制到 Extensions\php\php8.2.9nts\ext\
这个目录下即可
配置php.ini
添加参数
extension_dir="你的PHP目录\ext"
;用于获取扩展目录
修改的php.ini文件
[Xdebug]
zend_extension="D:/phpstudy_pro/Extensions/php/php8.2.9nts/ext/php_xdebug.dll"
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.auto_trace=Off
;xdebug.trace_output_dir="D:/phpstudy_pro/Extensions/php_log/php8.2.9nts.xdebug.trace" ; This directive has been renamed
xdebug.output_dir="D:/phpstudy_pro/Extensions/php_log/php8.2.9nts" ; Use this new directive for both trace and profiler output
xdebug.profiler_enable=Off
;xdebug.profiler_output_dir="D:/phpstudy_pro/Extensions/php_log/php8.2.9nts.xdebug.profiler" ; This directive has been renamed
xdebug.remote_enable=Off
xdebug.client_host="localhost"
xdebug.client_port=9003
xdebug.mode="debug,coverage"
;xdebug.remote_host="localhost" ; This directive has been renamed to xdebug.client_host
;xdebug.remote_port=9000 ; This directive has been renamed to xdebug.client_port
;xdebug.remote_handler="dbgp" ; This directive may not be necessary or may have changed
;xdebug.start_with_request = trigger ; This directive may not be necessary or may have changed
[Xdebug]是PHP的一个扩展,用于调试PHP代码。以下是配置文件的中文解释:
zend_extension=“D:/phpstudy_pro/Extensions/php/php8.2.9nts/ext/php_xdebug.dll”
加载Xdebug扩展的DLL文件。
xdebug.collect_params=1
收集函数的参数信息。
xdebug.collect_return=1
收集函数的返回值信息。
xdebug.auto_trace=Off
关闭自动跟踪功能。
;xdebug.trace_output_dir=“D:/phpstudy_pro/Extensions/php_log/php8.2.9nts.xdebug.trace” ; This directive has been renamed
跟踪输出的目录已重命名,不再使用。
xdebug.output_dir=“D:/phpstudy_pro/Extensions/php_log/php8.2.9nts” ; Use this new directive for both trace and profiler output
指定跟踪和性能分析输出的目录。
xdebug.profiler_enable=Off
关闭性能分析器功能。
;xdebug.profiler_output_dir=“D:/phpstudy_pro/Extensions/php_log/php8.2.9nts.xdebug.profiler” ; This directive has been renamed
性能分析输出目录已重命名,不再使用。
xdebug.remote_enable=Off
关闭远程调试功能。
xdebug.client_host=“localhost”
指定客户端主机名为localhost。
xdebug.client_port=9003
指定客户端端口号为9003。
xdebug.mode=“debug,coverage”
设置Xdebug的模式为调试和代码覆盖率。
;xdebug.remote_host=“localhost” ; This directive has been renamed to xdebug.client_host
远程主机名已重命名,不再使用。
;xdebug.remote_port=9000 ; This directive has been renamed to xdebug.client_port
远程端口号已重命名,不再使用。
;xdebug.remote_handler=“dbgp” ; This directive may not be necessary or may have changed
远程处理器可能不再需要或已更改。
;xdebug.start_with_request = trigger ; This directive may not be necessary or may have changed
启动请求的触发器可能不再需要或已更改。
在新版xdebug某些配置已经不再使用或已经更名
vscode安装phpDebug
设置中搜索php找到php设置setting.json添加如同下面的内容
{
"[php]": {},
"extensions.autoUpdate": "onlySelectedExtensions",
"php.validate.executablePath": "D:\\phpstudy_pro\\Extensions\\php\\php8.2.9nts\\php.exe",
"php.debug.executablePath": "D:\\phpstudy_pro\\Extensions\\php\\php8.2.9nts\\php.exe",
"editor.fontSize": 20,
"open-php-html-js-in-browser.selectedBrowser": "Edge",
"cmake.showOptionsMovedNotification": false
}
设置中找到phpdebug添加如同下面的内容
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9000,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
参考文章:
详见:
vscode使用xdebug3进行PHP调试_vscode xdebug3 配置-CSDN博客
vscode+xdebug+phpstudy本地调试php代码-猫叔的编程圈 (maoshu.fun)