PHPのバージョンを7.0に変更する
El Capitanにダウングレードしたので以前の7.0の環境がふっとんだのでこれを気にPHPのバージョンアップです。
前提
OS X El Capitan 10.11.6
問題
実際PHP操作する際はLaravel HomesteadかLaradock使うので基本問題ない。
ただ、Visual Studio Codeで操作する際にPHP 7じゃないけど?とERROR?WARNING?出てくるのでPHPバージョンあげます。
バージョン前
Macにはインストール時からPHPインストールされています。
1 2 3 4 5 |
% php -v PHP 5.5.38 (cli) (built: Aug 8 2017 12:56:53) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies |
バージョン5.5.38って結構新しいですね(笑
ただLaravel – 5.5は PHP – 7.0以降必要です
インストール
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
brew install homebrew/php/php70 ... The php.ini file can be found in: /usr/local/etc/php/7.0/php.ini ✩✩✩✩ Extensions ✩✩✩✩ If you are having issues with custom extension compiling, ensure that you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH: PATH="/usr/local/bin:$PATH" PHP70 Extensions will always be compiled against this PHP. Please install them using --without-homebrew-php to enable compiling against system PHP. ✩✩✩✩ PHP CLI ✩✩✩✩ If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent configuration file: export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH" ✩✩✩✩ FPM ✩✩✩✩ To launch php-fpm on startup: mkdir -p ~/Library/LaunchAgents cp /usr/local/opt/php70/homebrew.mxcl.php70.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist The control script is located at /usr/local/opt/php70/sbin/php70-fpm OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH: PATH="/usr/local/sbin:$PATH" You may also need to edit the plist to use the correct "UserName". Please note that the plist was called 'homebrew-php.josegonzalez.php70.plist' in old versions of this formula. With the release of macOS Sierra the Apache module is now not built by default. If you want to build it on your system you have to install php with the --with-httpd option. See brew options php70 for more details. To have launchd start homebrew/php/php70 now and restart at login: brew services start homebrew/php/php70 ==> Summary 🍺 /usr/local/Cellar/php70/7.0.25_17: 337 files, 39.0MB |
1 2 3 4 |
✩✩✩✩ PHP CLI ✩✩✩✩ If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent configuration file: export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH" |
1 2 3 4 5 6 7 8 |
//bashの場合 .zshrc -> .bashrc に変更してください。 vim ~/.zshrc //追加 export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH" //適応 source ~/.zshrc |
インストール後
1 2 3 4 5 |
% php -v PHP 7.0.25 (cli) (built: Oct 27 2017 12:56:30) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies |
これでERRORでなくなります。おしまい
コメントを残す