vscode+phpstudy+xdebug无法断点(踩坑记)

一、软件下载

安装vscode、下载phpstudy最新版这2步都不说了,网上大把教程。本文主要把phpstudy的一个坑点记录一下

vscode下载地址:
https://code.visualstudio.com/

phpstudypro下载地址:
通过百度网盘分享的文件:phpstudypro_x64_8.1.1.3.zip
链接:https://pan.baidu.com/s/1wzm0sqZCQS4NxvIf1jSrtw?pwd=6c6j
提取码:6c6j

二、phpstudy配置

配置网站

image

配置伪静态

location / {
        if (!-e $request_filename) {
            rewrite ^(.*)$ /index.php?s=$1 last;
            break;
        }
        try_files $uri $uri/ =404;
    }

image

开启phpxdebug
image

开启后,查看 xdebug 信息 phpinfo.php
image

配置php设置xdebug
image

三、vscode安装插件

image

vscode 配置 launch.json

{
    "configurations": [
      
      {
        "name": "Listen for Xdebug",
        "type": "php",
        "request": "launch",
        "stopOnEntry": true,
        "port": 9002
      },
    {
      "name": "Launch currently open script",
      "type": "php",
      "request": "launch",
      "program": "${file}",
      "cwd": "${fileDirname}",
      "port": 9002, 					
      "runtimeArgs": [
        "-dxdebug.start_with_request=yes"
      ],
      "env": {
        "XDEBUG_MODE": "debug,develop",
        "XDEBUG_CONFIG": "client_port=${port}"
      }
    }
    ]
  }
  

装完插件,然后配置插件:File--Preferences--Settings--Extensions--PHP:
image

写入你要用的php版本所在位置:

"php.validate.executablePath": "D:\\phpstudypro\\Extensions\\php\\php7.1.9nts\\php.exe"

四、配置php.init

image

[Xdebug]
zend_extension="D:\phpstudypro\Extensions\php\php7.1.9nts\ext\php_xdebug.dll"
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.auto_trace=On
xdebug.trace_output_dir="D:\phpstudypro\Extensions\php_log\php7.1.9nts.xdebug.trace"
xdebug.profiler_enable=On
xdebug.profiler_output_dir="D:\phpstudypro\Extensions\tmp\xdebug"
xdebug.remote_enable=On
xdebug.remote_autostart = On
xdebug.remote_host=localhost
xdebug.remote_port=9002
xdebug.remote_handler=dbgp
xdebug.remote_autostart = 1
xdebug.remote_log = D:/phpstudypro/Extensions/tmp/xdebug/log/php/xdebug2.log

重启WNMP
image

重启网站
image

五、测试断点

打断点
image

启动监听debug程序
按F5 或者 点启动按钮
image

http请求接口
image

进入断点
image

参考文档:
https://zhuanlan.zhihu.com/p/113171737

posted @ 2024-10-22 20:45  HaimaBlog  阅读(35)  评论(0编辑  收藏  举报