macos安装php及xdebug


macos下安装php环境主要用于cli的运行和调试

搜索PHP

brew search php

返回结果:

==> Formulae
brew-php-switcher   php-cs-fixer        php@7.3             phpmyadmin
php                 php@7.1 ✔           phplint             phpstan
php-code-sniffer    php@7.2             phpmd               phpunit

==> Casks
homebrew/cask/eclipse-php               homebrew/cask/netbeans-php

安装php7.1:brew install php@7.1

安装xdebug:/usr/local/opt/php@7.1/bin/pecl install xdebug

相关配置文件:/usr/local/etc/php/7.1/

zsh下另一种用法:

$(brew --prefix php@7.1)/bin/php --version
$(brew --prefix php@7.1)/bin/pecl install xdebug

==============华丽丽的分割线=================

Installing and running older PHP versions

(Note: Homebrew removes unsupported PHP versions, if you need something really old, get binaries from https://php-osx.liip.ch)
Sometimes you want to test your software against older PHP.

Here is how to set it up PHP7.2 (thanks Mike):
brew install php@7.2

$(brew --prefix php@7.2)/bin/pecl install --force xdebug
$(brew --prefix php@7.2)/bin/php -S 127.0.0.1:8080

Here you can run phpunit with older PHP version:
$(brew --prefix php@7.2)/bin/php vendor/bin/phpunit

To switch default PHP version entirely:
php unlink php
php link php@7.2
php --version

Next, lets switch back to latest PHP:
brew unlink php@7.2
brew link php

PHPStorm can be configured with multiple PHP versions.

参考:macos安装php和xdebug

Archives