Installing IMAP extension on PHP 7.2 on macOS High Sierra 10.13.6

IMAP extension is no more shipped since PHP 7.1 in the brew package because its considered to be unstable. However if you use it already, you probably need it in your development environment.

First become admin and install with brew PHP 7.2:
$ sudo su – admin
$ brew install [email protected]

Get PHP 7.2 source code which has included the IMAP module:

$ curl http://nc1.php.net/get/php-7.2.8.tar.gz/from/this/mirror > php_7.2.8.tar.gz
$ tar xfzv php_7.2.8.tar.gz
$ cd ext/imap
$ phpize
$ LDFLAGS=“-lssl -lcrypto“ ./configure –with-kerberos
$ make
$ make install

# Now add the extension in your php.ini file:
$ vi /usr/loca/etc/php/7.2/php.ini

Add at the top of the file the following line:
extension=“imap.so“