PHPBrewでiconv拡張をインストール

1. 環境

インストールする環境はこんな感じ

$ sw_vers
ProductName:	macOS
ProductVersion:	11.3
BuildVersion:	20E232

$ phpbrew --version
phpbrew - 1.27.0
cliframework core: 2.5.4

$ phpbrew list
* php-7.4.13
  php-7.3.25

$ php -v
PHP 7.4.13 (cli) (built: Dec  4 2020 21:48:53) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

libiconv はインストール済

$ brew install libiconv

2. インストール

まずは失敗したケースから

$ phpbrew ext install iconv
===> Installing iconv extension...
Log stored at: /Users/YOUR_USER_NAME/.phpbrew/build/php-7.4.13/ext/iconv/build.log
Changing directory to /Users/YOUR_USER_NAME/.phpbrew/build/php-7.4.13/ext/iconv
===> Phpize...
===> Configuring...
Error: Command failed: ./configure '--with-php-config=/Users/YOUR_USER_NAME/.phpbrew/php/php-7.4.13/bin/php-config' >> '/Users/YOUR_USER_NAME/.phpbrew/build/php-7.4.13/ext/iconv/build.log' 2>&1 returns:

エラーログをみると --with-iconv を指定する必要があるようなので

checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for iconv support... yes, shared
checking for iconv... no
checking for libiconv... no
configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>

改めて

$ phpbrew ext install iconv -- --with-iconv=$(brew --prefix libiconv)
===> Installing iconv extension...
Log stored at: /Users/YOUR_USER_NAME/.phpbrew/build/php-7.4.13/ext/iconv/build.log
Changing directory to /Users/YOUR_USER_NAME/.phpbrew/build/php-7.4.13/ext/iconv
===> Phpize...
===> Configuring...
===> Building...
===> Running make all: /usr/bin/make -C '/Users/YOUR_USER_NAME/.phpbrew/build/php-7.4.13/ext/iconv' 'all'  >> '/Users/YOUR_USER_NAME/.phpbrew/build/php-7.4.13/ext/iconv/build.log' 2>&1
===> Installing...
===> Running make install: /usr/bin/make -C '/Users/YOUR_USER_NAME/.phpbrew/build/php-7.4.13/ext/iconv' 'install'  >> '/Users/YOUR_USER_NAME/.phpbrew/build/php-7.4.13/ext/iconv/build.log' 2>&1
===> Extension is installed.
===> Creating config file /Users/YOUR_USER_NAME/.phpbrew/php/php-7.4.13/var/db/iconv.ini.disabled
===> Enabling extension iconv
[*] iconv extension is enabled.
Done.
$ phpbrew ext |grep iconv
 [*] iconv        7.4.13

3. iniの場所

$ head ~/.phpbrew/php/php-7.4.13/var/db/iconv.ini
extension=iconv.so