PHP7に上がりましたが、それ以前にcakeがversion3になっていますね。
いずれはこれでリプレイスをしなくてはいけないので、今日とりあえずインストールしてみました。
原則としてcomposerが入っていないとうごきませんね。
Contents
インストール
ルートディレクトリ(例 /var/www/html)の下で
1 |
composer create-project --prefer-dist cakephp/app [appName] |
と入力すればOKです。
インストール後,
1 2 |
cd [appName] composer install |
でライブラリを入れてあげればOKです。
また
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Problem 1 - cakephp/cakephp 3.2.9 requires ext-intl * -> the requested PHP extension intl is missing from your system. - 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.13 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.2.12 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.2.11 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.2.10 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/cakephp 3.2.0 requires ext-intl * -> the requested PHP extension intl is missing from your system. - Installation request for cakephp/cakephp ~3.2 -> satisfiable by cakephp/cakephp[3.2.0, 3.2.1, 3.2.10, 3.2.11, 3.2.12, 3.2.13, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.2.7, 3.2.8, 3.2.9]. |
のようなエラーが入っている場合、
1 |
yum install --enablerepo=remi --enablerepo=remi-php56 -y php-intl(php5.6の場合) |
でintlをインストールしてあげればOKです。
また設定ファイルをコピーしてあげましょう
1 |
cp -ip ./config/app.default.php ./config/app.php |
また
1 |
Fatal error: You must enable the intl extension to use CakePHP. in C:\xampp\htdocs\cakephp3\config\bootstrap.php on line 38 |
というエラーがでた場合、下記のような対策を取ります。
該当箇所のファイルと行数を見てあげると下記の部分になります。
1 2 3 4 |
// You can remove this if you are confident you have intl installed. if (!extension_loaded('intl')) { trigger_error('You must enable the intl extension to use CakePHP.', //E_USER_ERROR); } |
どうやら国際化?関連の記述のようでintlという拡張機能がインストールされていれば削除してもOKなようです。
正しくはphp.iniでこの設定を有効(extension=php_intl.dll)にすることなんですが(リンク参照)、自分の場合、php7の入れ方がおかしかったので該当箇所がなかったために、上の命令をコメントアウトすることに。
※php5.6では追加したところ有効になりました。
この状態でhttp://domain/[appName]にアクセスするとなんとか、起動ができました。
※cake3の場合、ビルトインサーバーがあるようなのですが、私は通常通りapacheで動かしています。
とりあえず今日はここまでで。
参考リンク
春だし CakePHP 3.0をComposer経由でCentOS6.5にインストール してみた
CakePHP3.0をインストールしてみる(自分用めもめも)
ComposerでCakephp3をインストールしようとしてハマった件
intlに関して
初心者でもできる!さっそくCakePHP3.0をインストールしてみよう!
cake3の初期設定
cake3をインストールしてまずしておいたほうが良い設定など。
データベースの設定
config/app.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
'Datasources' => [ 'default' => [ 'className' => 'Cake\Database\Connection', 'driver' => 'Cake\Database\Driver\Mysql', 'persistent' => false, 'host' => '', 'username' => '', 'password' => '', 'database' => '', 'encoding' => 'utf8', 'timezone' => 'Asia/Tokyo', 'flags' => [], 'cacheMetadata' => true, 'log' => true, |
まずはdatabaseのhost,username,password,databaseなどを設定してあげればOKです。
あとは時間を日本時間しておきましょう。またログがあったほうがやはり記録を追うのにいいのでlog=>trueにしておきましょう。
ちなみに日本時間がMySQLで設定されていないときは下記リンクの方法で設定してあげましょう。
app/bootstrap.php
1 |
date_default_timezone_set('Asia/Tokyo'); |
こちらも日本時間にしておいたほうがあとあと便利でしょう。