先看一下有哪些版本的 php
Kyle@Kyles-MBP ~ % brew search php
==> Formulae
brew-php-switcher php-cs-fixer phplint phpstan
php php@7.2 phpmd phpunit
php-code-sniffer php@7.3 phpmyadmin
然后安装你需要的
在 ~/.bash_profile 中添加以下两行
export PATH="/usr/local/opt/php@7.3/bin:$PATH"
export PATH="/usr/local/opt/php@7.3/sbin:$PATH"
将修改应用一下
source ~/.bash_profile
此时再查看 php -version
Kyle@Kyles-MBP ~ % php -version
PHP 7.3.23 (cli) (built: Oct 5 2020 15:56:32) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.23, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.23, Copyright (c) 1999-2018, by Zend Technologies
再查看是哪个 php 程序
Kyle@Kyles-MBP ~ % which php
/usr/local/opt/php@7.3/bin/php
Kyle@Kyles-MBP ~ % pecl install xdebug
安装成功之后,再 php -version
已经能看到 xdebug 了
Kyle@Kyles-MBP ~ % php -version
PHP 7.3.23 (cli) (built: Oct 5 2020 15:56:32) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.23, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans
with Zend OPcache v7.3.23, Copyright (c) 1999-2018, by Zend Technologies