Closed SimonZhangCN closed 5 years ago
按照官方文档中的MongoDB示例,在如下文件中会出先MongoDB\CLient类找不到的问题,
namespace App\Mongodb; use EasySwoole\EasySwoole\Trigger; use EasySwoole\SyncInvoker\AbstractInvoker; use MongoDB\Client; class Driver extends AbstractInvoker { private $db; function getDb():Client { if($this->db == null){ $mongoUrl = "mongodb://127.0.0.1:27017"; $this->db = new Client($mongoUrl); } return $this->db; } protected function onException(\Throwable $throwable) { Trigger::getInstance()->throwable($throwable); return null; } }
php --ri mongodb打印信息如下,文档中也没有写明mongdb扩展的版本
php --ri mongodb
MongoDB support => enabled MongoDB extension version => 1.5.5 MongoDB extension stability => stable libbson bundled version => 1.13.0 libmongoc bundled version => 1.13.0 libmongoc SSL => enabled libmongoc SSL library => OpenSSL libmongoc crypto => enabled libmongoc crypto library => libcrypto libmongoc crypto system profile => disabled libmongoc SASL => disabled libmongoc ICU => disabled libmongoc compression => enabled libmongoc compression snappy => disabled libmongoc compression zlib => enabled Directive => Local Value => Master Value mongodb.debug => no value => no value
这边只是例子,实际上 MongoDB\Client; 是 composer require mongodb/mongodb 来的
按照官方文档中的MongoDB示例,在如下文件中会出先MongoDB\CLient类找不到的问题,
php --ri mongodb
打印信息如下,文档中也没有写明mongdb扩展的版本