vscode调试php

php版本:7.2.3

1.安装xdebug

通过phpinfo();发现没有xdebug,所以需要下载安装xdebug,下载网址:https://xdebug.org/download,下载对应版本即可。

image.png

下载完成后将下载的文件放在:/php/ext目录下,如下图:
image.png

2.修改php.ini配置文件,在php.ini文件中添加

[XDebug]
zend_extension=E:\myServer\php\ext\php_xdebug-3.0.4-7.2-vc15-x86_64.dll
php-cgi.exe -b 127.0.0.1:9000-c E:/myServer/php/php.ini
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9000
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

3.配置vscdoe

(1)安装php debug

image.png

(2)配置vscode

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        },
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 8089
        }
    ]
}
image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容