Environment
- macOS Sierra Version 10.12.4
- Xcode:
xcode-select --install
Homebrew
Install PHP
安装PHP:
1 | # 快速安装php,参考 https://github.com/Homebrew/homebrew-php |
配置PHP:
1 | # 配置 /private/etc/php.ini |
安装 PEAR 和 PECL:
1 | # 参考 https://jason.pureconcepts.net/2012/10/install-pear-pecl-mac-os-x/ |
如果要安装多个版本的PHP
1 | # 用于在不同版本的php之间切换,参考 https://github.com/philcook/brew-php-switcher |
Install Composer
1 | > brew install composer |
Install PHP Extension
Install intl
安装
1 | > brew install autoconf |
检查是否安装成功:
1 | > php -m | grep intl # 正常会包含 intl |
Install OPcache
1 | > brew install php56-opcache |
Install Xdebug
安装:
1 | > brew install php56-xdebug |
The Xdebug extension will be enabled per default after the installation, additional configuration of the extension should be done by adding a custom ini-file to /usr/local/etc/php/<php-version>/conf.d/
.
配置:
1 | > sudo echo 'xdebug.remote_enable=1 |
安装xdebug-osx
(xdebug
开关工具):
1 | > brew install xdebug-osx |
Use PHPStorm as IDE
Config Language & Frameworks
打开Preferences > Languages & Frameworks > PHP
添加CLI Intepreter
Config Xdebug
打开Preferences > Languages & Frameworks > PHP > Debug
如何配置参考Configuring Xdebug in PhpStorm
验证
创建一个PHP项目,新建一个php
文件,创建执行配置:
打上断点,以Debug
方式运行: