mongodbmacosmampphp-mongodb

Build/Install Mongodb PHP extension on MAMP and Mac arm64 (Big sur)


Recently switched to the arm64 mac platform but since I'm having trouble installing/building the mongodb php extension using Mamp.

I have tried the following :

CFLAGS="-arch x86_64" CPPFLAGS="-arch x86_64" CXXFLAGS="-arch x86_64" ./configure --target=x86_64

And all possible variation using those parameters but nothing is working.

Getting the following error :

    [02-Feb-2021 18:09:00 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/mongodb.so (dlopen(/Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/mongodb.so, 9): no suitable image found.  Did find:
        /Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/mongodb.so: mach-o, but wrong architecture
        /Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/mongodb.so: mach-o, but wrong architecture), /Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/mongodb.so.so (dlopen(/Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug
-non-zts-20190902/mongodb.so.so, 9): image not found)) in Unknown on line 0

And when installing with pecl : CFLAGS="-arch i386" sudo pecl install mongodb-1.5.4

Getting the following error : [04-Feb-2021 09:10:14 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/mongodb.so (dlopen(/Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/mongodb.so, 9): Library not loaded: libicuuc.56.dylib Referenced from: /Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/mongodb.so Reason: image not found), /Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/mongodb.so.so (dlopen(/Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/mongodb.so.so, 9): image not found)) in Unknown on line 0

Anyone you successfully did what I'm trying to do ?


Solution

  • Managed to installed it with pecl using :

    sudo pecl install -a mongodb