安装 VSCode Php Debug 扩展
-
运行 VSCode
-
打开扩展

- 输入 PHP Debug

- 安装

安装 Php Xdebug 扩展
-
在 http://pecl.php.net/ 搜索 xdebug ,并下载 php xdebug 扩展,下载的扩展需匹配本地 php 以下三要素(可以通过 phpinfo() 函数查看):
1)PHP Version
2)Architecture:x86?x64?
3)PHP Extension Build:TS?NTS? -
将下载下来的 php_xdebug.dll 放入 php 扩展目录,可在 php.ini 中搜索关键字 extension_dir 查看扩展目录路径
extension_dir="E:\WAMPP\Install\php\ext"
- 在 php.ini 文件中添加 php xdebug 扩展
[XDebug]
zend_extension = "D:\Work\XAMPP\php\ext\php_xdebug.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
- 重启 PHP 服务
php 文件调试
- 在需要调试的行数前右键选择断点类型,为该行打断点,然后点击左侧第4个图标,打开调试界面

- 选择"添加配置"

- 选择环境 - php

- 运行调试 Listen for XDebug

- 在浏览器中访问 php 文件,VSCode 会命中打断点的地方
网友评论