Fatal error: Class 'MongoDB\Driver\Manager' not found

后端 未结 7 818
攒了一身酷
攒了一身酷 2020-12-01 18:52

I want to use the MongoDB Driver, but it throw me an error, when i use it:

$mongo = new MongoDB\\Driver\\Manager(\"mongodb://localhost:27017\");
相关标签:
7条回答
  • 2020-12-01 19:51

    How to install on macOS Mojave

    Start with:

    sudo pecl install mongodb
    

    To check if mongodb package is installed, look for "mongodb" when you run:

    pecl list
    

    To get your installed mongodb.so path, run:

    pecl list-files mongodb | grep mongodb.so
    

    then remove (or comment out) on your php.ini file:

    extension="mongodb.so"
    

    (I could not found a line with extension="php_mongodb.so")

    now insert a line with:

    extension="{{the path to your installed mongodb.so}}"
    

    Run this command to get your ext-*.ini directory path:

    php -i | grep Scan
    

    Create your ext-mongodb.ini with:

    touch {{your conf.d path}}/ext-mongodb.ini
    

    like:

    touch /usr/local/etc/php/7.1/conf.d/ext-mongodb.ini
    

    Restart your apache to read the new configuration

    Sanity check with:

    php -i | grep mongodb
    

    You're ready to go.

    0 讨论(0)
提交回复
热议问题