1. 程式人生 > >mac php新增mongodb擴充套件

mac php新增mongodb擴充套件

1、下載安裝mongo驅動擴充套件包

$ git clone https://github.com/mongodb/mongo-php-driver.git
$ cd mongo-php-driver
$ git submodule update --init
$ phpize
$ ./configure
$ make all
$ sudo make install

2、修改php.ini,

sudo vi /usr/local/php/lib/php.ini

新增

extension=mongodb.so

不知道php.ini位置的可以這樣找

normanyangtekiMacBook-Pro:mongo-php-driver normanyang$ php --ini
Configuration File (php.ini) Path: /usr/local/php/lib
Loaded Configuration File:         /usr/local/php/lib/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

3、重啟apache

sudo apachectl restart

4、檢視php當前支援

php -m

[PHP Modules]
Core
ctype
curl
date
dom
ereg
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
memcache
memcached
mongodb
mysql

可以看到mongodb已經支援

5、如果你在laravel裡面開發,新增mongdb支援

composer require jenssegers/mongodb:3.0.2