ClassNotFoundException:尝试加载类" FlattenException"从命名空间

时间:2014-03-28 13:58:58

标签: symfony sonata-admin doctrine-odm

我正在使用Symfony 2.4和doctrine mongodb bundle开发一个应用程序。我遇到了一个令人讨厌的错误:

  

ClassNotFoundException:尝试从/opt/apps/aff/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Cursor.php中的命名空间“Symfony \ Component \ Debug \ Exception”加载类“FlattenException”第455行。您是否需要从其他命名空间“使用”它?也许你需要为以下之一添加一个use语句:Symfony \ Component \ HttpKernel \ Exception \ FlattenException,Symfony \ Component \ Debug \ Exception \ FlattenException。

特别是在访问sonata admin bundle的列表方法时会发生此错误。我在玩存储库classess时也遇到过这个错误。

确切的代码在远程服务器上运行良好。但是在本地机器上出现了这个错误。我不知道为什么。我在终端上运行了以下代码,以查看版本号或git commit ref代码。

$ php composer.phar show -i

两台计算机上的结果完全相同。以下是我的composer.json

{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
    "psr-0": { "": "src/" }
},
"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "~2.4",
    "twig/extensions": "~1.0",
    "symfony/assetic-bundle": "~2.3",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~2.3",
    "sensio/framework-extra-bundle": "~2.3",
    "sensio/generator-bundle": "~2.3",
    "incenteev/composer-parameter-handler": "~2.0",

    "doctrine/mongodb-odm": "1.0.*@dev",
    "doctrine/mongodb-odm-bundle": "3.0.*@dev",
    "doctrine/doctrine-fixtures-bundle": "dev-master",

    "gedmo/doctrine-extensions": "dev-master",

    "jms/serializer-bundle" : "dev-master",

    "friendsofsymfony/user-bundle": "*",
    "friendsofsymfony/facebook-bundle": "1.2.*@dev",
    "friendsofsymfony/rest-bundle" : "dev-master",

    "nelmio/api-doc-bundle" : "dev-master",

    "sonata-project/core-bundle": "~2.2@dev",
    "sonata-project/admin-bundle": "2.2.*@dev",
    "sonata-project/doctrine-mongodb-admin-bundle":"dev-master",
    "sonata-project/block-bundle": "2.2.*@dev",
    "sonata-project/user-bundle": "2.2.3",
    "sonata-project/easy-extends-bundle" : "dev-master",
    "sonata-project/intl-bundle": "dev-master",

    "knplabs/knp-menu-bundle":"1.1.x-dev",
    "zeitnot/cp_oauth_client" : "dev-master"


},
"scripts": {
    "post-install-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "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": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "php app/console assets:install --symlink",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ]
},
"config": {
    "bin-dir": "bin"
},
"minimum-stability": "beta",
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml",
        "keep-outdated": true        
    },
    "branch-alias": {
        "dev-master": "2.4-dev"
    }
}

}

我真的很困惑,我不知道如何处理。这个恼人的例外是什么意思?

1 个答案:

答案 0 :(得分:1)

我有同样的事情,错误是由Cursor.php中的hint()方法中的错误参数类型强制的。并且PHP的PHP严格标准错误设置正在为此创建错误。这可能是它在远程服务器上正常工作的原因(不同的PHP设置)。

现在问题已解决,因此更新MongoDB供应商应该解决它。 More information