LoginSignup
4
3

More than 5 years have passed since last update.

phpbrewでintl拡張インストールがエラーになる場合の対応方法

Posted at

久しぶりにCakePHPを使うことになり、ローカルにphpbrewでintl拡張をインストールしようとしたらハマったので、tipsを共有します。

phpbrew に intl 拡張がインストールできない

$ phpbrew install 7.1.10 +openssl=$(brew --prefix openssl) +intl を実行してみたところ、以下のようなエラーになりました。

Error: Make failed:
The last 5 lines in the log file:
/usr/local/Cellar/icu4c/59.1/include/unicode/unistr.h:3180:7: error: delegating constructors are permitted only in C++11

      UnicodeString(Char16Ptr(buffer), buffLength, buffCapacity) {}

      ^~~~~~~~~~~~~

2 warnings and 3 errors generated.

make: *** [ext/intl/intl_convertcpp.lo] Error 1

とりあえずググる

以下のようなサイトを見つけました

PHPBrewに"intl"拡張をインストール - まったり技術ブログ

なるほど、と、思ったのですが、 なんかもっと簡単な解決策ないのか?と思います(よね?)。

応援がくる

php-build いいな...

公式のissueから探す

phpbrew公式のgithub issueから C++11 で検索してみます。
すると、ありました。

I cannot install PHP 7.1.9 on macOS 10.11.6 (El Capitan) #899

patrickjahns さんのコメントをみて、これはオプションでいけるんじゃない?と気づきます。

This problem is related to icu4c version 59.1.

Install an older version of icu4c (i.e. 58.2) and manually link against it:
--with-icu-dir=/usr/local/Cellar/icu4c/58.2/

なるほど、icu4cは何が入っているか調べてみると、 58.2 もありました。

$ ls /usr/local/Cellar/icu4c
57.1    58.2    59.1

オプション付きで拡張を入れてみる

実はすでに phpbrew で 7.1.10 はインストール済みだったので、拡張だけインストールしました。

$ phpbrew ext install intl -- --with-icu-dir=/usr/local/Cellar/icu4c/58.2/
===> Installing intl extension...
Log stored at: /.phpbrew/build/php-7.1.10/ext/intl/build.log
Changing directory to /.phpbrew/build/php-7.1.10/ext/intl
===> Phpize...
===> Configuring...
===> Building...
===> Running make all: /usr/bin/make -C '/.phpbrew/build/php-7.1.10/ext/intl' 'all'  >> '/.phpbrew/build/php-7.1.10/ext/intl/build.log' 2>&1
===> Installing...
===> Running make install: /usr/bin/make -C '/.phpbrew/build/php-7.1.10/ext/intl' 'install'  >> '/.phpbrew/build/php-7.1.10/ext/intl/build.log' 2>&1
===> Extension is installed.
===> Creating config file /.phpbrew/php/php-7.1.10/var/db/intl.ini.disabled
===> Enabling extension intl
[*] intl extension is enabled.
Done.

おー、インストールできた。

まとめ

  • twitterの愚痴に対して応援があると助かる
  • 公式のissueがcloseになっていなくても有益がコメントがある
  • なるべく簡単な方法を探そう

今後、phpbrewでintl拡張入れる人の手助けになれば幸いです。

4
3
1

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
4
3