一天的整理,僅供參考!
$a=new Mongo();上述代碼執行時會報錯,如下所示:
Fatal error: Class 'Mongo' not found in /Users/mfw/PhpstormProjects/KeenSting/control/exprement.php on
line 17
我安裝的是MAMP集成開發環境
phpstorm中的配置如下
查了很久的資料才發現是MAMP中的php沒有擴展mongodb功能,系統自帶的php我倒是撞了mongodb但是因爲缺少php-cgi,所以根本沒什麼卵用--網頁直接輸入localhost:27017可以接入mac自帶的php所擴展的mongo,而phpstorm職能連mamp,mamp沒有mongo,所以就要給他裝上
開始安裝
1,這裏要用到brew安裝,沒有的可以去度娘找找homebrew安裝的教程,比較快,但是需要XCODE的支持,沒有的去applestore down一個吧,免費,安裝完需要啓動一次再退出
Starting to download mongo-1.6.10.tgz (209,087 bytes)
.............................................done: 209,087 bytes
118 source files, building
running: phpize
grep: /Applications/MAMP/bin/php/php5.6.10/include/php/main/php.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.6.10/include/php/Zend/zend_modules.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.6.10/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
Starting to download mongo-1.6.10.tgz (209,087 bytes)
.............................................done: 209,087 bytes
118 source files, building
running: phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
Cannot find autoconf. Please check your autoconf installation and the
Warning: You have an outdated version of /usr/bin/install_name_tool installed.
This will cause binary package installations to fail.
This can happen if you install osx-gcc-installer or RailsInstaller.
To restore it, you must reinstall OS X or restore the binary from
the OS packages.
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.yosemite.bott
######################################################################## 100.0%
==> Pouring autoconf-2.69.yosemite.bottle.1.tar.gz
downloading mongo-1.6.10.tgz ...
Starting to download mongo-1.6.10.tgz (209,087 bytes)
..........................................done: 209,087 bytes
118 source files, building
running: phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
Installing '/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/mongo.so'
install ok: channel://pecl.php.net/mongo-1.6.10
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongo.so" to php.ini