VS Code phpStudy2018 PHP-7.0.12-NTS + Nginx 配置XDebug

IDE: VS Vode   Server:phpStudy2018   切换为PHP-7.0.12-Nginx版本 

1.  其他选项菜单→PHP扩展及设置→PHP扩展→勾选Xdubug

2.  打开配置文件PHP.ini 注意对应版本 修改文本末尾

  1. xdebug.profiler_output_dir="D:\phpStudy\PHPTutorial\tmp\xdebug"
    xdebug.trace_output_dir="D:\phpStudy\PHPTutorial\tmp\xdebug"
    zend_extension="D:\phpStudy\PHPTutorial\php\php-7.0.12-nts\ext\php_xdebug.dll"
    xdebug.remote_port = 9001
    xdebug.remote_autostart= On
    xdebug.remote_enable = On

注意xdebug.remote_port = 9001,xdebug.remote_port这个设置,默认是9000,但fast-cgi的默认端口也是9000,Nginx使用的fast-cgi端口也是9000,所以修改为9001。经本人测试如不修改也不抛错,debug时浏览器会卡住不动,不能正常访问项目。

3.  VS Code 文件→首选项→设置→用户设置 User Settings文件修改PHP可执行文件配置

  1. "php.validate.executablePath": "D:\\phpStudy\\PHPTutorial\\php\\php-7.0.12-nts\\php.exe",

注意匹配版本

4.  VS Code安装 PHP Debug插件 点击左上角配置小图标修改lauch.json文件

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9001
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9001
        }
    ]
}

注意是port是9001,与PHP.ini xdebug.remote_port 一致

点击行号打断点,F5或者小三角图标启动, F10在断点所在方法内单步执行  F11进入调用方法内部调试。
左侧变量、监视、调用堆栈、断点四栏显示相关Debug信息。

参考文章:https://blog.csdn.net/cyan007/article/details/51684119

你可能感兴趣的:(Nginx)