当前位置:Gxlcms > PHP教程 > MAC系统下phpstorm不能基于MAXP使用MongoDB的结局办法

MAC系统下phpstorm不能基于MAXP使用MongoDB的结局办法

时间:2021-07-01 10:21:17 帮助过:16人阅读

一天的整理,仅供参考!

$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一个吧,免费,安装完需要启动一次再退出


2,安装mongodb(需要root权限 控制台输入sudo -s,回车后输入密码即可)

bash-3.2# /Applications/MAMP/bin/php/php5.6.10/bin/pecl install mongo

结果出错

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
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.

ERROR: `phpize' failed

3,找到include文件夹(软连接,关联文件夹)

bash-3.2# sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include /Applications/MAMP/bin/php/php5.6.10/include

再次运行

结果还是有问题

bash-3.2# /Applications/MAMP/bin/php/php5.6.10/bin/pecl install mongo

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
Cannot find autoconf. Please check your autoconf installation and the

$PHP_AUTOCONF environment variable. Then, rerun this script.

ERROR: `phpize' failed

4,说是找不到autoconfig,那就安装!!(这里要退出root状态)

KeenStings-MacBook-Pro:~ mfw$ brew install autoconf
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

�? /usr/local/Cellar/autoconf/2.69: 70 files, 3.1M


5,安装完了执行

KeenStings-MacBook-Pro:~ mfw$ sudo /Applications/MAMP/bin/php/php5.6.10/bin/pecl install mongo

提示

Password:
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

Build with Cyrus SASL (MongoDB Enterprise Authentication) support? [no]

6,输入yes回车就好了

很长一段提示信息

最后是这个

Build process completed successfully
Installing '/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/mongo.so'
install ok: channel://pecl.php.com/mongo-1.6.10
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongo.so" to php.ini

KeenStings-MacBook-Pro:~ mfw$

7,到你的位置去吧php.ini中加入extension=mongo.so 即可

看教程就一回,但是我找了一天的资料==


版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了MAC系统下phpstorm不能基于MAXP使用MongoDB的结局办法,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

人气教程排行