PHP7.0+Wamp64环境下MongoDB扩展加载异常及Laravel类找不到求助
Fixing 'MongoDB\Driver\Manager' Not Found in Laravel with PHP 7.0 + Wamp64
Hey there, let's work through this extension loading issue step by step—since phpinfo isn't showing MongoDB at all, the core problem is that the extension isn't being loaded properly by PHP. Here's what to check:
1. Double-Check Your Extension File Compatibility
First, make sure you downloaded the exact right version of the MongoDB PHP extension:
- You're using PHP 7.0 x64 (Wamp64), so grab the TS (Thread Safe) build compiled with VC14 (PHP 7.0 requires VC14).
- Place the
php_mongodb.dllfile into your Wamp PHP extension directory—this should be something likewamp64/bin/php/php7.0.[your-minor-version]/ext/(don't put it in Apache's ext folder!).
2. Edit the Correct php.ini File
Wamp has multiple php.ini files—don't waste time editing the wrong one:
- Open your phpinfo page, look for the
Loaded Configuration Fileline to get the exact path of the php.ini PHP is using. - Open that file, and add this line (no need for full paths, PHP will use the
extension_dirsetting):extension=php_mongodb.dll - Verify the
extension_dirsetting is correct—it should point to your PHP ext folder, e.g.:extension_dir = "ext" # Or absolute path like: extension_dir = "C:/wamp64/bin/php/php7.0.33/ext"
3. Restart All Wamp Services
Don't just restart Apache—restart the entire Wamp stack:
- Right-click the Wamp tray icon > Restart All Services.
- After restarting, refresh your phpinfo page and search for "mongodb"—you should now see a dedicated section for the extension.
4. Verify Laravel Setup
Once the extension is loading, make sure your Laravel config is correct:
- Ensure you've installed a compatible MongoDB package for PHP 7.0—run this Composer command (version 3.6.x works for PHP 7.0):
composer require jenssegers/mongodb:3.6.* - Update your
config/database.phpto include the MongoDB connection:'connections' => [ // ... your other connections 'mongodb' => [ 'driver' => 'mongodb', 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', 27017), 'database' => env('DB_DATABASE', 'your_database'), 'username' => env('DB_USERNAME', ''), 'password' => env('DB_PASSWORD', ''), 'options' => [ 'database' => 'admin' // Optional, for authentication ] ], ], - Set your
DB_CONNECTIONin.envtomongodb.
5. Check for Common Pitfalls
- If you had the old
mongoextension (notmongodb) installed before, remove anyextension=php_mongo.dlllines from php.ini to avoid conflicts. - Check PHP's error log (Wamp tray > PHP > PHP error log) for specific loading errors—this will tell you if the DLL is missing, corrupted, or incompatible.
内容的提问来源于stack exchange,提问作者Marouane Sihad
相关产品推荐
相关产品推荐

