LoginSignup
7
14

More than 5 years have passed since last update.

【OSX】CakePHP3のインストール in XAMPP

Last updated at Posted at 2016-10-28

OSXでCakePHP3をインストールしたので、ログに残す。

xamppをインストール

公式ページからインストールしてください。php5.6でおk.

composerをインストール

macにデフォルトでインストールされているターミナルを開いて作業してください。
え? 黒い画面怖い? 怖くないよ。おいでおいでヘ( ̄ー ̄ )

xamppのhtdocsへ移動して、composerをインストールしましょう

$ cd /Applications/XAMPP/htdocs/
$ curl -s https://getcomposer.org/installer | /Applications/XAMPP/bin/php

cakephp3をインストール

先ほどインストールしたcomposerを使って、CakePHP3をインストールする。

# `cakephp` ってディレクトリが作成される.
$ /Applications/XAMPP/bin/php composer.phar create-project --prefer-dist cakephp/app cakephp

しかし、、、

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.

こんなエラーがでたと思う。

これはphpの拡張ライブラリがインストールされていなから(だと思う)。

すんなり入ればラッキーだと思うが、エラーがでた人はこのライブラリを使用するために、インストールが必要。

intlをインストール

順にコマンドをタイプしていけばおk

# PHPのパスをXAMPPのものにする
$ PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}"

# icu4cをインストール
$ brew install icu4c

# autoconfをインストール
$ brew install autoconf

# intlをインストール
$ sudo pecl update-channels
$ sudo pecl install intl 

コメントもらいました。
使用しているOSのバージョンによっては、intlのインストール手順が macOS Sierra 10.12.4 で上手くいかないようです。

以下のように icu4c インストール時に --force を付けると入るようです。

# PHPのパスをXAMPPのものにする
$ PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}"

# icu4cをインストール
$ brew install --force icu4c

# icu4cをリンクさせる
$ brew link --force icu4c

# autoconfをインストール
$ brew install autoconf

# intlをインストール
$ sudo pecl update-channels
$ sudo pecl install intl 

とりあえずintlがインストールできればおk。

php.iniを編集する

intlライブラリを認識させるために、php.iniファイルを修正する。

$ sudo vi /Applications/XAMPP/etc/php.ini
# ;extension=php_intl.dll
# の行を
# extension=intl.so に変更.
extension=intl.so

編集したら、xamppのapacheを再起動してください。エラー無く起動したらおkです。

CakePHP3を再度インストールしてみる

さきほど途中までインストールしたCake3の残骸が残っているので一旦削除。

その後にcomposerを使ってインストールする。

$ rm -rf cakephp/

# 再度cakephpをインストール
$ /Applications/XAMPP/bin/php composer.phar create-project --prefer-dist cakephp/app cakephp

インストールできたかなー?
お疲れ様でした。

参考にしたURL

7
14
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
14