IntelliJですばやくCakePHP環境を構築する


【参考】
[IntelliJですばやくPHP開発環境を構築する](http://qiita.com/master-of-sugar/items/64955c57f95bc89dedcd)

↑の記事でPHPの環境自体はほとんどOK。

しいていうとMacのデフォルトPHPのバージョンを上げる際にちょっとハマった。。。

## PHPのバージョンアップでハマったよ

これだけ叩いとけばいいと思ってたら

```
brew update
brew install php56
```

うひゃー

```
Error: No available formula with the name "php56" 
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
These formulae were found in taps:
homebrew/php/php56-amqp            homebrew/php/php56-ioncubeloader   homebrew/php/php56-pdo-dblib       homebrew/php/php56-swoole        
homebrew/php/php56-apcu            homebrew/php/php56-jsmin           homebrew/php/php56-pdo-pgsql       homebrew/php/php56-symfony-debug 
homebrew/php/php56-augmentedtypes  homebrew/php/php56-judy            homebrew/php/php56-phalcon         homebrew/php/php56-thrift        
homebrew/php/php56-binpack         homebrew/php/php56-kafka           homebrew/php/php56-pimple          homebrew/php/php56-tidy          
homebrew/php/php56-blitz           homebrew/php/php56-leveldb         homebrew/php/php56-pinba           homebrew/php/php56-timecop       
homebrew/php/php56-boxwood         homebrew/php/php56-libevent        homebrew/php/php56-proctitle       homebrew/php/php56-timezonedb    
homebrew/php/php56-chdb            homebrew/php/php56-libsodium       homebrew/php/php56-propro          homebrew/php/php56-twig          
homebrew/php/php56-couchbase       homebrew/php/php56-libvirt         homebrew/php/php56-protobuf        homebrew/php/php56-uopz          
homebrew/php/php56-crypto          homebrew/php/php56-lz4             homebrew/php/php56-pspell          homebrew/php/php56-uploadprogress
homebrew/php/php56-dbase           homebrew/php/php56-lzf             homebrew/php/php56-pthreads        homebrew/php/php56-uuid          
homebrew/php/php56-dbus            homebrew/php/php56-magickwand      homebrew/php/php56-qr              homebrew/php/php56-v8js          
homebrew/php/php56-dmtx            homebrew/php/php56-mailparse       homebrew/php/php56-raphf           homebrew/php/php56-varnish       
homebrew/php/php56-eio             homebrew/php/php56-maxminddb       homebrew/php/php56-rdkafka         homebrew/php/php56-vld           
homebrew/php/php56-ev              homebrew/php/php56-mcrypt          homebrew/php/php56-redis           homebrew/php/php56-wbxml         
homebrew/php/php56-event           homebrew/php/php56-mecab           homebrew/php/php56-redland         homebrew/php/php56-xcache        
homebrew/php/php56-fast_assert     homebrew/php/php56-memcache        homebrew/php/php56-riak            homebrew/php/php56-xdebug        
homebrew/php/php56-gearman         homebrew/php/php56-memcached       homebrew/php/php56-runkit          homebrew/php/php56-xhgui         
homebrew/php/php56-geoip           homebrew/php/php56-meminfo         homebrew/php/php56-scrypt          homebrew/php/php56-xhprof        
homebrew/php/php56-gmagick         homebrew/php/php56-midgard2        homebrew/php/php56-snappy          homebrew/php/php56-xmldiff       
homebrew/php/php56-gmp             homebrew/php/php56-mongo           homebrew/php/php56-snmp            homebrew/php/php56-xxtea         
homebrew/php/php56-gnupg           homebrew/php/php56-mongodb         homebrew/php/php56-sodium          homebrew/php/php56-yac           
homebrew/php/php56-graphdat        homebrew/php/php56-mosquitto       homebrew/php/php56-solr            homebrew/php/php56-yaf           
homebrew/php/php56-grpc            homebrew/php/php56-msgpack         homebrew/php/php56-sphinx          homebrew/php/php56-yaml          
homebrew/php/php56-hprose          homebrew/php/php56-mustache        homebrew/php/php56-spl-types       homebrew/php/php56-yar           
homebrew/php/php56-htscanner       homebrew/php/php56-mysqlnd_ms      homebrew/php/php56-ssh2            homebrew/php/php56-yaz           
homebrew/php/php56-http            homebrew/php/php56-oauth           homebrew/php/php56-stats           homebrew/php/php56-yp            
homebrew/php/php56-httpparser      homebrew/php/php56-opcache         homebrew/php/php56-stemmer         homebrew/php/php56-yrmcds        
homebrew/php/php56-igbinary        homebrew/php/php56-parsekit        homebrew/php/php56-suhosin         homebrew/php/php56-zmq           
homebrew/php/php56-imagick         homebrew/php/php56-pcntl           homebrew/php/php56-sundown         homebrew/php/php56-zookeeper     
homebrew/php/php56-intl            homebrew/php/php56-pdflib          homebrew/php/php56-svm             homebrew/php/php56               
To install one of them, run (for example):
  brew install homebrew/php/php56-amqp
```

調べてみるとあったあった。
[macにhomebrewでPHP5.6環境をインストールしてみる](http://takemaru123.hatenablog.jp/entry/2014/11/27/224037)

リポジトリを作成する必要があるらしい。

```
brew tap homebrew/php
brew tap homebrew/dupes
```

仕切りなおして・・・

```
brew install php56
php -v
```

ちゃんと5.6に

```
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
```

これを待っていたのだよ。
あとは入れたパスを指定してInterpreterを5.6に。
![Kobito.YxvZFe.png](https://qiita-image-store.s3.amazonaws.com/0/127115/cf2b22fb-83fe-b8b7-dfa7-cb7064b13eae.png "Kobito.YxvZFe.png")

## Cakeを入れるよ

【参考】
[OS X で PhpStorm で Composer 使って CakePHP 2.5 入れてあとテスト](http://qiita.com/hidashun/items/09a1977a8f0f8f630c98)
[Composerを利用したCakePHP2.4.xの導入手順](http://www.pupha.net/archives/1751/)

プロジェクト作ったらついにCakeを入れる。
PHPのパッケージ管理ツールである`composer`を入れて使ってみる。

```
brew install composer
```

作成したプロジェクト直下に`composer.json`を作成して必要なモジュール（と呼ぶのか？）を定義してインストール。

```composer.json
{
  "name": "hello-cake",
  "repositories": [
    {
      "type": "pear",
      "url": "http://pear.cakephp.org"
    }
  ],
  "require": {
    "cakephp/cakephp": "3.2.9"
  },
  "require-dev": {
    "phpunit/phpunit": "5.4.*",
    "cakephp/debug_kit": "3.2.9"
  },
  "config": {
    "vendor-dir": "Vendor/"
  }
}
```


```
php composer.phar install
```

どひゃー

```
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package pear-cakephp/cakephp could not be found in any version, there may be a typo in the package name.
  Problem 2
    - cakephp/debug_kit 3.2.0 requires cakephp/cakephp 3.1.* -> satisfiable by cakephp/cakephp[3.1.0, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.13, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9].
    - cakephp/debug_kit 3.2.1 requires cakephp/cakephp 3.1.* -> satisfiable by cakephp/cakephp[3.1.0, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.13, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9].
    - cakephp/debug_kit 3.2.2 requires cakephp/cakephp 3.1.* -> satisfiable by cakephp/cakephp[3.1.0, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.13, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9].
    - cakephp/debug_kit 3.2.3 requires cakephp/cakephp >=3.1.0 -> satisfiable by cakephp/cakephp[3.1.0, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.13, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9, 3.2.0, 3.2.1, 3.2.10, 3.2.11, 3.2.12, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.2.7, 3.2.8, 3.2.9].
    - cakephp/debug_kit 3.2.4 requires cakephp/cakephp >=3.1.0 <4.0 -> satisfiable by cakephp/cakephp[3.1.0, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.13, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9, 3.2.0, 3.2.1, 3.2.10, 3.2.11, 3.2.12, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.2.7, 3.2.8, 3.2.9].
    - cakephp/debug_kit 3.2.5 requires cakephp/cakephp >=3.1.0 <4.0 -> satisfiable by cakephp/cakephp[3.1.0, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.13, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9, 3.2.0, 3.2.1, 3.2.10, 3.2.11, 3.2.12, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.2.7, 3.2.8, 3.2.9].
    - cakephp/debug_kit 3.2.6 requires cakephp/cakephp >=3.1.0 <4.0 -> satisfiable by cakephp/cakephp[3.1.0, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.13, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9, 3.2.0, 3.2.1, 3.2.10, 3.2.11, 3.2.12, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.2.7, 3.2.8, 3.2.9].
    - cakephp/debug_kit 3.2.7 requires cakephp/cakephp >=3.1.0 <4.0 -> satisfiable by cakephp/cakephp[3.1.0, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.13, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9, 3.2.0, 3.2.1, 3.2.10, 3.2.11, 3.2.12, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.2.7, 3.2.8, 3.2.9].
    - cakephp/debug_kit 3.2.8 requires cakephp/cakephp >=3.1.0 <4.0 -> satisfiable by cakephp/cakephp[3.1.0, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.13, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9, 3.2.0, 3.2.1, 3.2.10, 3.2.11, 3.2.12, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.2.7, 3.2.8, 3.2.9].
    - cakephp/debug_kit 3.2.9 requires cakephp/cakephp >=3.1.0 <4.0 -> satisfiable by cakephp/cakephp[3.1.0, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.13, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9, 3.2.0, 3.2.1, 3.2.10, 3.2.11, 3.2.12, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.2.7, 3.2.8, 3.2.9].
    - 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.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.
    - cakephp/cakephp 3.1.9 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.8 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.7 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.6 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.5 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.4 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.3 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.2 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.13 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.12 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.11 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.10 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.1 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.1.0 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - Installation request for cakephp/debug_kit 3.2.* -> satisfiable by cakephp/debug_kit[3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.2.7, 3.2.8, 3.2.9].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
  To enable extensions, verify that they are enabled in those .ini files:
    - /usr/local/etc/php/5.6/php.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
```

たぶん`the requested PHP extension intl is missing from your system`が肝な気がする。`php-intl`なる拡張機能があり、そいつを入れろよ、ということのようなので入れて仕切りなおす。今度こそ

```
brew install php56-intl
composer install
```

はいきた。

<img src="https://qiita-image-store.s3.amazonaws.com/0/127115/3d3d845f-4c4b-be1c-e925-ad01ed2085e0.png" width=" 300px"/>

cakeプロジェクトを作成!!!!

```
php composer.phar create-project --prefer-dist -s dev cakephp/app hello-cake
```

cake serverでテストページが立ち上がります。

```
hello-cake/bin/cake server
```

![Kobito.Ykyzr3.png](https://qiita-image-store.s3.amazonaws.com/0/127115/0b2f05f9-71ab-7e7f-71bb-3468143e1d3e.png "Kobito.Ykyzr3.png")