CakePHP 3のインストール


CakePHP3系が出てマイナーバージョンも上がってきてそろそろ使ってみようかなと思ってきたので、ローカル環境にインストールしてみました。
ローカル環境はVagrantを使っています。
CentOS release 6.6 (Final)
PHP 5.6.10
psql (9.4.4)
環境はこんな感じです。

Composerのインストール
まず最初にComposerのインストールをします。既にインストール済みであれば必要ありません。

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
composer self-update

CakePHP3のインストール

環境が整ったところで、CakePHP3のインストールをしていきます。
公式サイトにインストールマニュアルがあるので一度目を通すといいかもしれません。
Quick Start Guide

composer create-project --prefer-dist cakephp/app [ディレクトリ名]

残念ながら、以下のようなエラーが出てしまいました。。。
php-intlが必要みたいなのでインストールします。

Problem 1
- cakephp/cakephp 3.0.x-dev requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.1.x-dev requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.8 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.7 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.6 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.5 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.4 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.3 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.2 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.1 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.0-beta3 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.0-beta2 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.0-beta1 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.0-alpha2 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.0-alpha1 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.0-RC2 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.0-RC1 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.0.0 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- Installation request for cakephp/cakephp ~3.0 -> satisfiable by cakephp/cakephp[3.0.0, 3.0.0-RC1, 3.0.0-RC2, 3.0.0-alpha1, 3.0.0-alpha2, 3.0.0-beta1, 3.0.0-beta2, 3.0.0-beta3, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.0.8, 3.1.x-dev, 3.0.x-dev].

PHP 5.6系をインストールするためremiリポジトリにしているため環境によって実行するコマンドは調整してください。

yum install --enablerepo=remi --enablerepo=remi-php56 php-intl

Dependencies Resolved

===============================================================================
 Package                     Arch     Version              Repository   Size
===============================================================================
Installing:
 php-intl                    x86_64   5.6.10-1.el6.remi    remi-php56   205 k
Installing for dependencies:
 libicu-last                 x86_64   50.1.2-11.el6.remi   remi         7.3 M

Transaction Summary
===============================================================================
Install       2 Package(s)

Total download size: 7.5 M
Installed size: 25 M
Is this ok [y/N]:y

これでインストールができたので、apacheをリスタートします。

/etc/init.d/httpd restart

CakePHP3のゴミが残っているので、削除します。

rm -rf [ゴミファイル]

再度、CakePHP3のインストールを実行します。

composer create-project --prefer-dist cakephp/app [ディレクトリ名]

├── bin
├── composer.json
├── composer.lock
├── config
├── index.php
├── logs
├── phpunit.xml.dist
├── plugins
├── README.md
├── src
├── tests
├── tmp
├── vendor
└── webroot
無事、インストールすることが出来ました。
私は、Cakeフォルダをドキュメントルートと同じ階層に配置したので、一手間加えました。

cp -aprv system/webroot html

移動したindex.phpのままでは動かないので、下記のように編集します。

require __DIR__ . DIRECTORY_SEPARATOR . '../[作成したディレクトリ名]/webroot' . DIRECTORY_SEPARATOR . 'index.php';

CakePHP インストール完了
以上で、インストールが完了するはずです。
書き込み権限がないとかエラーが出た場合は、エラーに従って修正してください。


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>