Home >Backend Development >PHP Tutorial >Solution to the problem that phpstorm cannot use MongoDB based on MAXP under MAC system

Solution to the problem that phpstorm cannot use MongoDB based on MAXP under MAC system

WBOY
WBOYOriginal
2016-08-08 09:20:15879browse

A day’s arrangement is for reference only!

$a=new Mongo(); When the above code is executed, an error will be reported, as shown below:

Fatal error: Class 'Mongo' not found in /Users/mfw/PhpstormProjects/KeenSting/control/exprement.php on line 17

I installed the MAMP integrated development environment

The configuration in phpstorm is as follows


After checking the information for a long time, I found that the php in MAMP did not extend the mongodb function. The system automatically I used php with mongodb, but because of the lack of php-cgi, it is of no use at all - directly input localhost:27017 on the web page to access the mongo extended by the php that comes with the mac, and the phpstorm function is connected to mamp, and mamp does not have mongo. , so you need to install it on him

Start the installation

1. Brew installation is required here. If you don’t have it, you can go to Du Niang to find a homebrew installation tutorial. It’s faster, but it requires XCODE support. If you don’t have it, go to applestore. Down one, it’s free. After installation, you need to start it once and then exit


2. Install mongodb (root permission is required. Enter sudo -s on the console and enter the password after pressing Enter)bash- 3.2# /Applications/MAMP/bin/php/php5.6.10/bin/pecl install mongoThe result is wrongdownloading 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' failed3, find the include folder (soft link, associated folder) 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 /includeRun againThe result is still a problembash-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' failed4, saying that autoconfig cannot be found, then install it! ! (To exit the root state here)KeenStings-MacBook-Pro:~ mfw$ brew install autoconfWarning
: 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 fromthe 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, after installation, execute KeenStings-MacBook-Pro:~ mfw$ sudo /Applications /MAMP/bin/php/php5.6.10/bin/pecl install mongoPromptPassword:
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, just enter yes and press EnterA long prompt message Finally this 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.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
KeenStings-MacBook-Pro:~ mfw$7, go to your location and add extension=mongo.so to php.ini and you can I just watched the tutorial once, but I searched for the information for a day==

Copyright statement: This article is the original article of the blogger and may not be reproduced without the permission of the blogger. .

The above introduces the solution to the problem that phpstorm cannot use MongoDB based on MAXP under the MAC system, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn