ITの隊長のブログ

ITの隊長のブログです。Rubyを使って仕事しています。最近も色々やっているお(^ω^ = ^ω^)

CakePHP3をインストール

(前もやった気がするけど。。。)

全然覚えていなかったのでメモ

環境

$ sw_vers 
ProductName:  Mac OS X
ProductVersion: 10.11.5
BuildVersion: 15F34

el capitanです。

php5.6をインストール

phpbrewphpenvとかでインストールしようとしたらapxsでハマる(´;ω;`)ブワッ

なので、プリインストールされているphpをバージョンアップしました。

$ brew update
$ brew upgrade
$ brew tap homebrew/php
$ brew tap homebrew/dupes
$ brew install php56 --with-apxs2=/usr/sbin/apxs 

==> Installing php56 from homebrew/php
Error: Cannot install homebrew/php/php56 because conflicting formulae are installed.

あらら

php55をunlinkして再度実行

$ brew unlink php55

$ brew install php56 --with-apxs2=/usr/sbin/apxs 
==> Summary
🍺  /usr/local/Cellar/php56/5.6.23: 331 files, 48.9M

おk

$ php -v
PHP 5.6.23 (cli) (built: Jun 24 2016 21:14:33) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

インストールしたいphpを使いたいので、Apache側の設定も変更する

$ sudo vim /etc/apache/httpd.conf

####
#LoadModule php5_module libexec/apache2/libphp5.so
LoadModule php5_module /usr/local/Cellar/php56/5.6.23/libexec/apache2/libphp5.so
####

intlをインストール

これがよくわかりませんが、国際用のアプリケーションを作成するときに使うモジュールらしい。

composerとかでもエラーが発生するので、今のうちにインストールしておく

$ brew install php56-intl

インストールしたら、php.iniに設定する

extension=intl.so

composerを使ってCakePHP3をインストール

$ composer  create-project --prefer-dist cakephp/app ${APP_NAME}

これでインストールできるはず。

ちなみに、先ほどのintlが入っていないとこうなる。

  Problem 1
    - cakephp/cakephp 3.2.8 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.2.7 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.2.6 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.2.5 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.2.4 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.2.3 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.2.2 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.2.1 requires ext-intl * -> the requested PHP extension intl is missing from your system.

cakephpの設定ファイルを修正

${APP_NAME}/config/app.default.phpとなっているはずなので、app.phpにリネームする。

tmpパーミッションを変更

$ chmod -R 777 ${APP_NAME}/tmp

これでおk

f:id:aipacommander:20160710141024p:plain