php 安装 Xdebug 小记
官方文档:https://xdebug.org/docs/install#pecl
os version:
php version:
PHP 7.4.32 (cli) (built: Sep 29 2022 10:45:51) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.32, Copyright (c), by Zend Technologies
homebrew version:
Homebrew 3.6.10
Homebrew/homebrew-core (git revision 98c836067d9; last commit 2022-11-09)
Homebrew/homebrew-cask (git revision 4e901c025d; last commit 2022-11-10)
pecl path:
pecl extension directory:
执行 pecl config-get ext_dir
/opt/homebrew/lib/php/pecl/20190902
这里需要先确认该目录是否存在,如果不存在会导致 Xdebug 安装失败,就需要手动创建。执行 mkdir -p /opt/homebrew/lib/php/pecl/20190902
即可。
最后执行 pecl install xdebug
即可完成安装。该命令会把 xdebug.so
安装到目录 /opt/homebrew/lib/php/pecl/20190902
中。并且会在 php.ini
文件的顶部添加zend_extension="xdebug.so"
。
执行 php -v
检查是否安装成功
PHP 7.4.32 (cli) (built: Sep 29 2022 10:45:51) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v3.1.6, Copyright (c) 2002-2022, by Derick Rethans
with Zend OPcache v7.4.32, Copyright (c), by Zend Technologies
安装成功提示:
Build process completed successfully
install ok: channel://pecl.php.net/xdebug-3.1.6
Extension xdebug enabled in php.ini