Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install mongodb php driver on MAMP with PHP7 on OS X?

I am having trouble installing the new mongoldb driver for PHP on MAMP 3.5 OS X El Capitan. I entered the PATH to the MAMP's php7 binaries. I have also downloaded php7 sources, unarchive and in /Applications/MAMP/bin/php/php7.0.0/ I have created a directory include where I moved the downloaded php source (renamed the containing directory as 'php'). So now I have /Applications/MAMP/bin/php/php7.0.0/include/php in addition to MAMP original files. I am not sure if I push something forward or not. When I run

sudo pecl install mongoldb

I've got the error bellow:

downloading mongodb-1.1.1.tgz ...
Starting to download mongodb-1.1.1.tgz (642,977 bytes)
.................................................................................................................................done: 642,977 bytes
349 source files, building
running: phpize
Configuring for:
PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012
cp: acinclude.m4: No such file or directory
cp: Makefile.global: No such file or directory
cp: config.sub: No such file or directory
cp: config.guess: No such file or directory
cp: ltmain.sh: No such file or directory
cp: run-tests*.php: No such file or directory
cat: acinclude.m4: No such file or directory
/Applications/MAMP/bin/php/php7.0.0/bin/phpize: line 155: /Applications/MAMP/bin/php/php7.0.0/lib/php/build/phpize.m4: No such file or directory
autoconf: error: no input file
ERROR: `phpize' failed

Does anybody managed to install the new mongodb php driver on MAMP on OS X? Do I make somethings wrong? Any suggestions?

Some links: http://mongodb.github.io/mongo-php-driver/#installation, https://github.com/mongodb/mongo-php-driver, https://pecl.php.net/package/mongodb

Thanks.

like image 601
Florin Sima Avatar asked Dec 30 '15 22:12

Florin Sima


2 Answers

It seems that MAMP 3.5's PHP 7.0.0 version is missing the build directory in the associated lib/php directory, which is why you're getting the error:

/Applications/MAMP/bin/php/php7.0.0/lib/php/build/phpize.m4: No such file or directory

Just copy the build directory from one of the other PHP versions, e.g. /Applications/MAMP/bin/php/php5.6.10/lib/php/build to /Applications/MAMP/bin/php/php7.0.0/lib/php/build.

I've installed a few PECL modules with this fix and they're working fine.

Hopefully this is just a mistake in the MAMP packaging and will be fixed in versions after 3.5.

like image 187
Talis Avatar answered Nov 10 '22 00:11

Talis


I had the same issue and this worked best for me:

$ brew tap homebrew/homebrew-php
$ brew install php70-mongodb

You'll need to update php.ini and add the following line:

extension="/usr/local/opt/php70-mongodb/mongodb.so"

Restart MAMP servers, and you're done!

like image 27
Michael Avatar answered Nov 09 '22 23:11

Michael