PHP7 pecl 安装 mongodb扩展 和 PHPLIB

发布时间:2020-07-02 21:58:55 作者:sendoffice
来源:网络 阅读:5924

安装PECL

//php版本 > 7

$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar

//php版本 < 7
$ yum install php-pear
//否则会报错PHP Parse error: syntax error, unexpected //'new' (T_NEW) in /usr/share/pear/PEAR/Frontend.php on //line 91

安装扩展

$ pecl install mongodb

And if I try to install mongodb for example, I'll get the same warnings as before with an extra "XML Extension not found" at the end.

I compared the "/usr/bin/pecl" with one from ubuntu and the only difference is the "-n" in the exec line :
alpine:
exec $PHP -C -n -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@"

-n meaning: "No configuration (ini) files will be used"
If not using conf, xml won't be loaded, so I'm pretty sure the "-n" should be removed.

I tested after removing it, and got no warning or anything and was able to install my extension.

以上问题的解决方式:
vi /usr/bin/pecl
remove -n para
删除 -n 参数

安装完毕后,添加库到php.ini


extension=mongodb.so

安装 PHPLIB

http://php.net/manual/zh/mongodb.tutorial.library.php
https://getcomposer.org/download/
安装完毕后,安装 PHP Library for MongoDB (PHPLIB)
$ composer require mongodb/mongodb``<br/>最新版本的命令是:<br/>$ composer.phar require mongodb/mongodb`

一切正确后,在当前目录下,生成:vendor目录,OK

推荐阅读:
  1. springboot Mongodb的集成与使用实例详解
  2. JAVA mongodb 聚合几种查询方式详解

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

mongodb php p7

上一篇:str_replace() 函数

下一篇:关于UIImagePickerViewController拍摄video的分辨率和方向的一些代码整理

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》