【CakePHP3系/MAMP】ComposerでCakePHP3系をインストール実行時、「Your requirements could not be resolved to an installable set of packages.」と怒られた時の解決方法
CakePHP3系をComposerを使ってインストールする際に、起きたエラーの解消方を記していきます。
1.実行環境・インストール内容
MacOS:High Sierra 10.13.6
MAMP:5.7
PHP:7.4.2 (最小5.6)
MySQL:5.7.26 (最小5.1)
Composer:1.10.8
インストール内容
CakePHP:3.8
2.実行内容・エラー内容
CakePHP3.8インストールコマンドを実行
composer create-project --prefer-dist cakephp/app:3.8.* cakephp3
本来であればこちらで、正常にインストールが実行され完了するはずが、
「要件をインストール可能なパッケージのセットに解決できない」とエラーが発生しました。
Your requirements could not be resolved to an installable set of packages. Problem 1 - cakephp/cakephp 3.8.9 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.8.8 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.8.7 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.8.6 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.8.5 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.8.4 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.8.3 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.8.2 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.8.13 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.8.12 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.8.11 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.8.10 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.8.1 requires ext-intl * -> the requested PHP extension intl is missing from your system. - cakephp/cakephp 3.8.0 requires ext-intl * -> the requested PHP extension intl is missing from your system. - Installation request for cakephp/cakephp 3.8.* -> satisfiable by cakephp/cakephp[3.8.0, 3.8.1, 3.8.10, 3.8.11, 3.8.12, 3.8.13, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9].
なぜか、CakePHP3.8系が正常にセットされインストールされない。。。
3.原因
ターミナルが見ているPHPがMAMPのPHPではなく、元からインストールされているPHPを見ていると起きてしまいます。
PHPの確認をします。
下記の通り表示されると思います。
$ which php /usr/bin/php
4.解決策
$ vi ~/.bashrc # 開いたファイルに追記します。 $ export PATH=/Applications/MAMP/bin/php/php7.4.2/bin:$PATH # :wq で保存します。 #変更を反映します。 $ source ~/.bashrc
再度、PHPの確認をします。
$ which php /Applications/MAMP/bin/php/php7.4.2/bin/php
上記の通り表示されていればOKです。
5.インストールの実施
再度、インストールの実行しましょう。
composer create-project --prefer-dist cakephp/app:3.8.* cakephp3
これでインストールは無事実行されます。
書き込み権限の許可を聞かれるので「Y」と答えればインストールは無事完了です。
Set Folder Permissions ? (Default to Y) [Y,n]? Y