vscode配置PHP Debug

约定不等于承诺〃 2023-08-17 16:49 203阅读 0赞

1、先在vscode中安装PHP Debug,在设置添加“php.validate.executablePath”项,选中对应版本的php.exe。

  1. "php.validate.executablePath": "d:\\wamp\\bin\\php\\php7.2.14\\php.exe",

2、按F5调试,选择PHP,就可以了,可能会配置失败。

3、按 Ctrl+Shift+D 打开调试面板,点击上面的小齿轮打开launch.json,如果出现“Listen for XDebug”和“Launch currently open script”,就证明成功了,

可以调试了。

4、如果发现没有,就需要手动添加了:

  1. {
  2. // 使用 IntelliSense 了解相关属性。
  3. // 悬停以查看现有属性的描述。
  4. // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
  5. "version": "0.2.0",
  6. "configurations": [
  7. {
  8. "name": "Listen for XDebug",
  9. "type": "php",
  10. "request": "launch",
  11. "port": 9000
  12. },
  13. {
  14. "name": "Launch currently open script",
  15. "type": "php",
  16. "request": "launch",
  17. "program": "${file}",
  18. "cwd": "${fileDirname}",
  19. "port": 9000
  20. }
  21. ]
  22. }

5、然后在随便一个页面输出一下phpinfo(); Ctrl+A 复制页面的内容到 https://xdebug.org/wizard.php 的文本框内,点击下面的 Analyse my phpinfo() output 按钮获取对应的xdebug.dll文件,下载下来放到当前版本php目录下的zend_ext文件夹内。

1235146-20190919220122046-133045681.png

1235146-20190919220146340-339096036.png

1235146-20190919220239963-706087637.png

1235146-20190919220256255-577758662.png

6、配置apache下的php.ini文件

  1. D:\wamp\bin\apache\apache2.4.37\bin\php.ini

[XDebug]
zend_extension = “D:/wamp/bin/php/php7.2.14/zend_ext/php_xdebug-2.6.1-7.2-vc15-x86_64.dll” :对应下载的xdebug的目录
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.romote_host=localhost
xdebug.remote_port=9000 //关键在于这个端口号要和launch.json配置的端口号对应起来。

然后重启服务器就ok啦。

转载于:https://www.cnblogs.com/xinchenhui/p/11552917.html

发表评论

表情:
评论列表 (有 0 条评论,203人围观)

还没有评论,来说两句吧...

相关阅读

    相关 PHP Debug实战技术

    老鸟有一本《PHP调试手册》在网络上风行,不管老鸟还是嫩鸟,这篇文章的作用是介绍一些简单易行的PHP调试实战技术,希望大家能提出宝贵意见,共同进步。 (一)打印输出 使用e