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

Symfony 3.4升级至6.2后MongoDB出现CommandSubscriber未找到错误

Symfony 6.2 接入MongoDB后报错:找不到类 "MongoDB\Driver\Monitoring\CommandSubscriber"

我将Symfony版本从3.4升级至6.2,大部分功能可正常运行,但接入MongoDB后出现以下错误:

加载"Doctrine\Bundle\MongoDBBundle\APM\StopwatchCommandLogger"时,找不到类"MongoDB\Driver\Monitoring\CommandSubscriber"

错误截图显示上述类找不到的相关提示。

以下是我的composer.json内容:

{
    "name": "symfony/framework-standard-edition",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-4": {
            "App": "src/"
        }
    },
    "require": {
        "php": ">=8.0",
        "ext-curl": "*",
        "ext-json": "*",
        "ext-mongodb": "*",
        "alcaeus/mongo-php-adapter": "1.2.2",
        "api-platform/core": "^3.2@dev",
        "aws/aws-sdk-php": "^3.209",
        "beberlei/doctrineextensions": "@stable",
        "doctrine/doctrine-fixtures-bundle": "3.4.2",
        "doctrine/doctrine-migrations-bundle": "3.3.x-dev",
        "doctrine/mongodb-odm": "2.6.x-dev",
        "doctrine/mongodb-odm-bundle": "4.6.x-dev",
        "doctrine/orm": "^2.5",
        "friendsofsymfony/rest-bundle": "3.3.*",
        "guzzlehttp/guzzle": "@stable",
        "jms/serializer-bundle": "^3.9",
        "nelmio/api-doc-bundle": "4.8.*",
        "nelmio/cors-bundle": "^2.2",
        "predis/predis": "^1.1",
        "sensio/framework-extra-bundle": "^6.1",
        "sinner/phpseclib-bundle": "dev-master",
        "symfony/dependency-injection": "6.3.x-dev",
        "symfony/dotenv": "v6.2.0",
        "symfony/framework-bundle": "6.2.x-dev",
        "symfony/mailer": "6.2.7",
        "symfony/monolog-bundle": "^3.1.0",
        "symfony/polyfill-apcu": "^1.0",
        "symfony/security-bundle": "6.3.x-dev",
        "symfony/twig-bundle": "6.3.x-dev",
        "symfony/validator": "6.3.x-dev",
        "twig/extensions": "^1.3",
        "twig/twig": "^1.0||^2.0",
        "willdurand/geocoder-bundle": "@stable"
    },
    "require-dev": {
        "symfony/phpunit-bridge": "^3.0"
    },
    "scripts": {
        "symfony-scripts": [
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile"
        ],
        "post-update-cmd": [
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile"
        ]
    },
    "config": {
        "optimize-autoloader": true,
        "process-timeout":  600,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true,
        "allow-plugins": {
            "symfony/flex": true,
            "php-http/discovery": true
        }
    },
    "provide": {
        "ext-mongo": "*",
        "ext-mongodb": "*"
    },
    "minimum-stability": "dev",
    "extra": {
        "symfony-app-dir": "app",
        "symfony-bin-dir": "bin",
        "symfony-var-dir": "var",
        "symfony-web-dir": "web",
        "symfony-tests-dir": "tests",
        "branch-alias": {
            "dev-master": "3.4.x-dev"
        }
    }
}

我已经搜索了3-4小时仍未找到解决方案,特此求助。

内容的提问来源于stack exchange,提问作者Asad Ali

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 05:35:14