doufuhao8085 2012-10-28 22:35
浏览 76
已采纳

Mongo / PHP包装器错误 - 如何让包装器工作?

I'm getting this error when trying to connect to a mongo server:

Unable to find the wrapper "mongodb" - did you forget to enable it when you configured PHP?

The connection string looks like this:

$conn = new Mongo("mongodb://XXXX:XXXX@XXX.member0.mongohq.com:10021/XXX",array("replicaSet" => 'rsname'));

I tried finding out qhat wrappers were available using:

var_dump(stream_get_wrappers());

and got the following:

array
  0 => string 'https' (length=5)
  1 => string 'ftps' (length=4)
  2 => string 'compress.zlib' (length=13)
  3 => string 'compress.bzip2' (length=14)
  4 => string 'php' (length=3)
  5 => string 'file' (length=4)
  6 => string 'glob' (length=4)
  7 => string 'data' (length=4)
  8 => string 'http' (length=4)
  9 => string 'ftp' (length=3)
  10 => string 'phar' (length=4)
  11 => string 'zip' (length=3)
  12 => string 'ssh2.shell' (length=10)
  13 => string 'ssh2.exec' (length=9)
  14 => string 'ssh2.tunnel' (length=11)
  15 => string 'ssh2.scp' (length=8)
  16 => string 'ssh2.sftp' (length=9)

I've checked the conf.d folders and they all seem to be in order form what I can see, so i'm not sure what I need to do to allow me to connect using the wrapper, as the example shows in the php docs example.

I'm running nginx / PHP 5.3.5-1ubuntu7.11

Ha anyone delat with this before, or able to offer some guidance? Thanks.

  • 写回答

1条回答 默认 最新

  • dtgj8529 2012-11-06 11:10
    关注

    Which version of Mongo php library are you using? I made a simple test like this using version 1.2.12:

    <?php
    
    $mongo = new Mongo('mongodb://host1.local:27019,host2.local:27020', array("replicaSet"=>'aaa'));
    
    $hosts = $mongo->getHosts();
    
    var_dump( $hosts );
    ?>
    

    and got absolutely no problem. ReplicaSet support through the php driver is available since request PHP-121 which goes back to version 1.0.9

    To be more concrete on answering your question, the mongo php driver does not use a connection wrapper. It has a connection parser. You can find more detailled info in the code itself: parser.c

    PS: Your ubuntu version is a bit old! Was released in 10/2007 and reached EOL on the 4/2009.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器