安装&启用 Xdebug
- 执行
php -i
,获取安装的 php 信息 - 将第一步的结果贴入 xdebug 安装向导(Xdebug: Support — Tailored Installation Instructions)中,点击分析;
- 根据分析生成的指示,按步骤安装 Xdebug
- 安装完成后,配置启用 xdebug,在
99-xdebug.ini
中添加xdebug.mode=debug xdebug.start_with_request=yes xdebug.client_host=127.0.0.1 xdebug.client_port=9003 xdebug.idekey=PHPSTORM
浏览器安装 Xdebug 插件
Browser debugging extensions | PhpStorm Documentation
开始调试
浏览器插件开启 Debug
,PHPStorm 开启监听即可
多版本 PHP 都需要单独编译安装
例如,默认 php 版本为最新 8.2.x,需要为 7.4 版本安装 xdebug。
大体步骤一直,有以下 2 个地方需要注意:
-
获取 phpinfo,可使用绝对路径执行 php -i
/opt/homebrew/Cellar/php@7.4/7.4.33_3/bin/php -i
-
执行
./configure
时要指定 php-config
./configure --with-php-config=/opt/homebrew/Cellar/php@7.4/7.4.33_3/bin/php-config