You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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.dll file into your Wamp PHP extension directory—this should be something like wamp64/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 File line 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_dir setting):
    extension=php_mongodb.dll
    
  • Verify the extension_dir setting 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.php to 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_CONNECTION in .env to mongodb.

5. Check for Common Pitfalls

  • If you had the old mongo extension (not mongodb) installed before, remove any extension=php_mongo.dll lines 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:13:29