PHP配置xdebug的方法

PHP配置xdebug的方法

一、 查看PHP对应的xdebug版本并下载

1、创建一个php文件,文件内容如下图,将这个文件放到Apache服务器访问根目录下

PHP配置xdebug的方法_第1张图片

2、重浏览器输入本地地址访问Apache服务器,查看相应的PHP版本

PHP配置xdebug的方法_第2张图片

 

 

 

3、将这个页面显示所有信息复制,访问网址https://xdebug.org/wizard.php,并将复制的信息粘贴到文本框里,点击下方的Analyse my phpinfo() output按钮

PHP配置xdebug的方法_第3张图片

 

 

 PHP配置xdebug的方法_第4张图片

  4、下载其建议的dll文件

PHP配置xdebug的方法_第5张图片

 

 

 

5、将下载的文件放到PHP的安装目录下的ext文件夹下,我这里用的是xampp集成软件

PHP配置xdebug的方法_第6张图片

6、找到PHP目录下的php.ini文件并打开,在文件内容最后一行下面输入

[xdebug]

zend_extension = D:\xampp\php\ext\php_xdebug-2.9.6-7.3-vc15.dll   //这个路径是刚才下载的那个dll文件存放的路径

xdebug.remote_enable=on

xdebug.remote_autostart=on

xdebug.remote_handler=dbgp

xdebug.remote_mode=req

xdebug.romote_host=localhost

xdebug.remote_port=9000

PHP配置xdebug的方法_第7张图片

7、在vscode上搜索phpdebug插件并安装

PHP配置xdebug的方法_第8张图片

8、打开launch.json文件并配置参数

{

    // 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": 9000

        },

        {

            "name": "Launch currently open script",

            "type": "php",

            "request": "launch",

            "program": "${file}",

            "cwd": "${fileDirname}",

            "port": 9000

        }

    ]

}

PHP配置xdebug的方法_第9张图片

9、打开VScode的设置"php.validate.executablePath": "D:\\xampp\\php\\php.exe",//这里是你php安装目录下的文件,如果没有内容就添加进去,如果有就修改

PHP配置xdebug的方法_第10张图片PHP配置xdebug的方法_第11张图片

10、启动xdebug,从浏览器访问你的项目,会跳转到你的代码,说明就成功了,你就可以利用php的调试查找你的代码的错误PHP配置xdebug的方法_第12张图片

 

你可能感兴趣的:(PHP配置xdebug的方法)