Symfony 4抛出UndefinedMethodException异常

时间:2018-11-28 19:33:36

标签: symfony symfony4

从今天开始,我一直遇到这个奇怪的问题。我目前正在使用以Symfony 4为基础的系统。在本地,它运行完美,没有任何问题。但是,当我将代码推送到Azure(完成部署并提供服务)时,在prod.log上会出现以下错误:

[2018-11-28 19:19:26] php.CRITICAL: Call to undefined method Doctrine\Common\Annotations\PhpParser::write() {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to undefined method Doctrine\\Common\\Annotations\\PhpParser::write() at D:\\home\\site\\wwwroot\\vendor\\symfony\\http-foundation\\Session\\Storage\\Handler\\StrictSessionHandler.php:64)"} []
[2018-11-28 19:19:26] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\UndefinedMethodException: "Attempted to call an undefined method named "write" of class "Doctrine\Common\Annotations\PhpParser"." at D:\home\site\wwwroot\vendor\symfony\http-foundation\Session\Storage\Handler\StrictSessionHandler.php line 64 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\UndefinedMethodException(code: 0): Attempted to call an undefined method named \"write\" of class \"Doctrine\\Common\\Annotations\\PhpParser\". at D:\\home\\site\\wwwroot\\vendor\\symfony\\http-foundation\\Session\\Storage\\Handler\\StrictSessionHandler.php:64)"} []

我已经清除了作曲家缓存,Symfony缓存,删除了整个vendor目录并运行了composer update(两次),希望可以解决此问题。

除了更改代码外,我没有进行任何其他更改。我到处都在搜索此Doctrine\Common\Annotations\PhpParser软件包,但是找不到与之真正相关的任何东西。这是我的composer.json

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.1.3",
        "ext-ctype": "*",
        "ext-curl": "^7.2",
        "ext-iconv": "*",
        "ext-intl": "*",
        "ext-json": "^1.6",
        "box/spout": "^2.7",
        "nikic/php-parser": "^4.1",
        "piwik/device-detector": "^3.11",
        "sensio/framework-extra-bundle": "^5.2",
        "symfony/asset": "4.1.*",
        "symfony/console": "4.1.*",
        "symfony/flex": "^1.1",
        "symfony/framework-bundle": "4.1.*",
        "symfony/monolog-bundle": "^3.3",
        "symfony/security-bundle": "4.1.*",
        "symfony/twig-bundle": "4.1.*",
        "symfony/validator": "4.1.*",
        "symfony/yaml": "4.1.*"
    },
    "require-dev": {
        "symfony/dotenv": "4.1.*",
        "symfony/maker-bundle": "^1.9",
        "symfony/profiler-pack": "^1.0",
        "symfony/var-dumper": "4.1.*",
        "symfony/web-server-bundle": "4.1.*"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "4.1.*"
        }
    }
}

这是否是某些必需软件包的问题?

1 个答案:

答案 0 :(得分:0)

原来我缺少包裹。 @EquaPro在评论中指出,https://community.qnx.com/sf/wiki/do/viewPage/projects.bsp/wiki/TiAm335Beaglebone PhpParser软件包的一部分,我的doctrine/common中的任何软件包都未安装该软件包。

可能的原因:当我遵循《安全性/身份验证》教程时,由于不打算使用它而决定不安装Doctrine。通过安装composer.json来修复它。