ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
# Xdebug **官网** - 中文网站:http://xdebug.org.cn/ - 官方网站:http://xdebug.org/ ## 安装 > [安装xdebug](https://xdebug.org/docs/install) 自行查找适合自己的方式,可通过`源码编译`,`apt包管理`,`pecl`, `宝塔面板php设置`等多种方式安装 <br/> ## 配置 ## fpm调试 编辑 [php.ini](php/php.ini) - xdebug 3.x.x: ``` [XDebug] xdebug.mode = debug xdebug.start\_with\_request = yes xdebug.client_port = 9000 ``` - xdebug 2.x.x: ``` [XDebug] xdebug.remote_enable = 1 xdebug.remote_autostart = 1 xdebug.remote_port = 9000 ``` **php-fpm 配置完成后需要重启php才能生效** ## cli调试 对于非 web 应用,例如定时任务或单元测试,可以直接在控制台进行调试。 php.ini ``` xdebug.idekey = "fuk" ``` 在使用php运行前,先定义环境变量; 一直开启终端调试可以加入到`.bashrc`中 ```shell export XDEBUG_CONFIG="idekey=fuk" php think file clear // or php test.php ``` ## VScode 配置 **准备** - 安装并配置完成`php-fpm` - 安装`vscode`的`php-xdebug`插件 在调试页面新建一个调试配置文件,选择语言`php` ``` { "name": "Listen for Xdebug", "type": "php", "request": "launch", "port": 9001 // 对应xdebug配置端口 } ``` **使用** - 按`F5`运行`Listen for Xdebug`调试配置 - 在你的php业务中打上一个断点,再去访问你的业务即可触发。