5

This is officially driving me nuts! I'm trying to work with a laravel package for imap functions and I've installed everything there but I get a missing class error for imap_open

I know this means the imap module is not installed, or is problematic, at the php level.

I've edited my php.ini file to have extension=imap and now when I run any php command from the terminal CLI I get PHP Warning: PHP Startup: Unable to load dynamic library 'imap' (tried: /usr/local/lib/php/pecl/20190902/imap (dlopen(/usr/local/lib/php/pecl/20190902/imap, 9): image not found), /usr/local/lib/php/pecl/20190902/imap.so (dlopen(/usr/local/lib/php/pecl/20190902/imap.so, 9): image not found)) in Unknown on line 0

When I navigate to user/local/lib/php I have a 7.4 folder, in that I have a conf.d folder, pear.conf file, php-fpm.consf file, php-fpm.d folder, and php.ini file

What do I need to do at this point?

Geoff_S
  • 4,917
  • 7
  • 43
  • 133
  • Have You tried this? https://stackoverflow.com/questions/51433648/adding-imap-to-php-7-2-on-osx – num8er Mar 08 '20 at 20:43
  • @num8er yes I did, and I was able to move the imap.so file into the local folders and uncomment the file in the php.ini file. Still while in the directory for this project typing ```php -m``` doesn't show imap – Geoff_S Mar 09 '20 at 17:27
  • seems `php -v` will show that it’s different than 7.4 – num8er Mar 09 '20 at 17:40
  • @num8er ok if I run php-v it shows version 7.3.9 but before that I get a startup error loading dynamic library 'imap' with ```code signature in (/usr/local/lib/php/pecl/20190902/imap.so) not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.)) in Unknown on line 0``` – Geoff_S Mar 09 '20 at 22:45
  • imap.so which You're talking about I don't know for which version of php is. but I recommend to remove it from pecl folder (and remove from configs if it's appearing again). then simply do steps in my answer below, I've done it locally and it works. – num8er Mar 09 '20 at 23:19

4 Answers4

12

I've upgraded my 7.3 to 7.4 and added imap extension which does not exist in pecl.

So steps are:

1) brew update

2) brew upgrade php

3) sudo rm /usr/local/lib/php/pecl/20190902/imap.so

4) brew tap kabel/php-ext

5) brew install php-imap

6) php -m | grep imap

num8er
  • 18,604
  • 3
  • 43
  • 57
  • OK I went through these steps exactly and the. last step gave me ```PHP Warning: PHP Startup: Unable to load dynamic library 'imap' (tried: /usr/local/lib/php/pecl/20190902/imap (dlopen(/usr/local/lib/php/pecl/20190902/imap, 0x0009): dlopen(): file not found: /usr/local/lib/php/pecl/20190902/imap), /usr/local/lib/php/pecl/20190902/imap.so (dlopen(/usr/local/lib/php/pecl/20190902/imap.so, 0x0009): dlopen(): file not found: /usr/local/lib/php/pecl/20190902/imap.so))``` – Geoff_S Mar 10 '20 at 16:22
  • then when I immediately run php-v in the command line I get 7.3.9 – Geoff_S Mar 10 '20 at 16:22
  • @TomN. as I said in comments above if it will be appearing again remove that imap.so from config (php.ini), since `brew install php-imap` installs it to different place – num8er Mar 10 '20 at 16:23
  • 1
    I did the sudo rm step in your answer, but when I run php --ini in the command line it still shows the config file it's using is at /etc/php.ini – Geoff_S Mar 10 '20 at 16:25
  • 1
    OK I removed extension=imap from that file and now php -m | grep imap returns nothing – Geoff_S Mar 10 '20 at 16:27
  • cause You're using php 7.3.9 – num8er Mar 10 '20 at 16:27
  • close terminal and open new one – num8er Mar 10 '20 at 16:27
  • run: `brew upgrade php` and after `php -v` – num8er Mar 10 '20 at 16:29
  • ok yes it does say php 7.4.3 now. so now the grep command gives ```PHP Warning: PHP Startup: Unable to load dynamic library 'imap' (tried: /usr/local/lib/php/pecl/20190902/imap (dlopen(/usr/local/lib/php/pecl/20190902/imap, 9): image not found), /usr/local/lib/php/pecl/20190902/imap.so (dlopen(/usr/local/lib/php/pecl/20190902/imap.so, 9): image not found)) in Unknown on line 0``` – Geoff_S Mar 10 '20 at 16:30
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/209386/discussion-between-num8er-and-tom-n). – num8er Mar 10 '20 at 16:30
  • After doing only (4) and (5) everything was upgraded anyway. So the result is a brand new PHP 8 installation (I had 7.4) – WeidMaster Jan 19 '21 at 14:19
  • 1
    Thank you. I'm using shivammatur on my big sur. tapping the shivammatur extensions didn't solve my problem but your answer did – Dika May 27 '21 at 02:14
6

It is a time to update the package. We need php@7.4-imap (actually its an alias to php-imap that loads php-8.0.0 source code.

Gassan
  • 81
  • 2
  • 4
5

I've tries all of the things. But, nothing works. Finally, I got Shivammathur git brew extensions -

Homebrew tap for PHP extensions - https://github.com/shivammathur/homebrew-extensions

Process to install imap extension for php 7.4 -

Get PHP 7.4 & Extensions:

brew tap shivammathur/php
brew install shivammathur/php/php@7.4
brew link --force --overwrite php@7.4
brew tap shivammathur/extensions

Get Any extension now, like imap

brew install imap@7.4

After then, I can perfectly enabled php-imap on my machine. Hope, it will help somebody.

Maniruzzaman Akash
  • 4,610
  • 1
  • 37
  • 34
-1

I would check to see if Step 1 is actually required, otherwise this worked for me on Mac OS 10 Catalina 10.15.1

brew install php@7.4-imap (not sure if required)
brew tap shivammathur/php
brew install shivammathur/php/php@7.4
brew services restart php
brew install imap@7.4
brew tap shivammathur/extensions\n
brew install imap@7.4\n
php -m | grep imap