Open renjie-run opened 3 years ago
在本文,主要记录了如何在 Mac + XAMPP 中配置 Xdebug。
Xdebug 要根据 PHP 版本下载指定的版本。如果不知道当前 PHP 版本要下载那个 Xdebug 时,可通过 https://xdebug.org/wizard 中的工具来帮助分析即可。
使用以下命令解压刚下载的 Xdebug 包,并进入到解压后的目录中。
tar -xvzf xdebug-x.x.x.tgz cd xdebug-x.x.x
phpize
这里 phpize 使用 XAMPP 自带的,执行如下命令即可。
/Applications/XAMPP/xamppfiles/bin/phpize
如图,表明执行成功。
如果出现 Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. 错误,表示缺少安装 autoconf。使用以下命令安装即可,安装完再次执行 phpize 命令应该就没问题了。
brew install autoconf
./configure
这里要指定 XAMPP 带的 php-config 否则最后生成的 xdebug.so 无法使用。
./configure --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config
make
这一步也是最后一步,出现如下结果,表明编译成功。
Build complete. Don't forget to run 'make test'.
此时,可以在 xdebug 目录下的 modules 文件夹里看到 xdebug.so 文件。
将 xdebug.so 拷贝到 /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-xxxx/ 这样的目录下即可。
最后,在 php.ini 文件配置 Xdebug 配置即可。Xdebug 参考配置如下
[Xdebug] zend_extension=/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20200930/xdebug.so xdebug.mode=debug xdebug.remote_autostart on xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=localhost xdebug.remote_port=9000 xdebug.idekey=PHPSTORM
配置完后,在 phpinfo 界面中可以找到对应的 Xdebug 配置,如果没有,Xdebug 未配置成功,需要做进一步的检查。
在本文,主要记录了如何在 Mac + XAMPP 中配置 Xdebug。
1.到官网下载 Xdebug
Xdebug 要根据 PHP 版本下载指定的版本。如果不知道当前 PHP 版本要下载那个 Xdebug 时,可通过 https://xdebug.org/wizard 中的工具来帮助分析即可。
2.解压下载的 Xdebug 包
使用以下命令解压刚下载的 Xdebug 包,并进入到解压后的目录中。
3.执行
phpize
命令这里 phpize 使用 XAMPP 自带的,执行如下命令即可。
如图,表明执行成功。
如果出现 Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. 错误,表示缺少安装 autoconf。使用以下命令安装即可,安装完再次执行 phpize 命令应该就没问题了。
4.执行
./configure
命令这里要指定 XAMPP 带的 php-config 否则最后生成的 xdebug.so 无法使用。
5.执行
make
命令这一步也是最后一步,出现如下结果,表明编译成功。
此时,可以在 xdebug 目录下的 modules 文件夹里看到 xdebug.so 文件。
将 xdebug.so 拷贝到 /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-xxxx/ 这样的目录下即可。
最后,在 php.ini 文件配置 Xdebug 配置即可。Xdebug 参考配置如下
配置完后,在 phpinfo 界面中可以找到对应的 Xdebug 配置,如果没有,Xdebug 未配置成功,需要做进一步的检查。