Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding IMAP to PHP 7.2 on OSX

I'm using PHP 7.2 on OS X El Capitan, installed using Homebrew (of course). Now I'd like to use some IMAP functions from PHP's IMAP extension, but no matter what I search for, I can't find a way to add the extension on OSX.

Some things I've tried... I have, of course, tried the most commonly recommended approach:

$ brew reinstall php --with-imap

Yet this fails, returning:

Warning: php: this formula has no --with-imap option so it will be ignored!

Another method, which I found mentioned in passing, also fails:

$ brew install php72-imap

Error: No available formula with the name "php72-imap" 
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

I'm not exactly sure which direction to go in with this. I'm sure there's an easy, probably documented, way of doing this, but I am yet to find it. Perhaps I'm just looking in the wrong places and using the wrong search terms...

like image 858
Laef Avatar asked Jul 20 '18 00:07

Laef


People also ask

How do I know if php-IMAP is installed?

To check if IMAP extension is installed, please run this command: php -m | grep imap.


Video Answer


2 Answers

Kevin Abel is providing some of the PHP extensions removed from Homebrew/core. You can install the IMAP extension with:

brew tap kabel/php-ext
brew install php-imap

To install a specific version, such as 7.2 use:

brew install [email protected]
like image 174
Ortomala Lokni Avatar answered Sep 20 '22 23:09

Ortomala Lokni


Here is how I solved this problem under Mojave:

First, I installed IMAP module for PHP 7.2

brew install kabel/php-ext/[email protected]

Secondly I copied the imap.so from installed folder to the 'extension_dir' used by php.ini

sudo cp /usr/local/lib/php/20170718/imap.so to /usr/local/lib/php/pecl/20170718
like image 31
Alex Avatar answered Sep 20 '22 23:09

Alex