VSCode配置PHP的Xdebug教程 - 如何进行调试

silverwq
2022-05-23 / 0 评论 / 308 阅读 / 正在检测是否收录...

概述

本篇文章介绍在vscode中调试php。

概述

  1. 首先需要安装好xdebug插件,已经配置好php的执行路径
  2. 然后配置在侧边栏的【运行和调试】菜单里新增配置文件,内容如下
    {
     // Use IntelliSense to learn about possible attributes.
     // Hover to view descriptions of existing attributes.
     // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
     "version": "0.2.0",
     "configurations": [
         {
             "name": "Listen for Xdebug",
             "type": "php",
             "request": "launch",
             "port": 9901,
             "xdebugSettings": {// 不然变量的名称太长的话只能查看部分
                 "max_depth": 10,// 这个顺序一定要放在max_data前面,不然watch里看不到内部调试
                 "max_data": -1,
                 "max_children": 100000,
             }
         },
         {
             "name": "Launch currently open script",
             "type": "php",
             "request": "launch",
             "program": "${file}",
             "cwd": "${fileDirname}",
             "port": 0,
             "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": 9901,
             "serverReadyAction": {
                 "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
                 "uriFormat": "http://localhost:%s",
                 "action": "openExternally"
             }
         }
     ]
    }
0

评论 (0)

取消