Symfony 4 抛出 UndefinedMethodException 异常

Symfony 4 throwing UndefinedMethodException exception

从今天开始我就遇到了这个奇怪的问题。我目前正在开发一个以 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.*"
        }
    }
}

这可能是某些必需软件包的问题吗?

原来我少了一个包裹。 @EquaPro 在评论中指出 PhpParserdoctrine/common 包的一部分,我的 composer.json 中的任何包都没有安装它。

可能的原因:当我在学习Security/Authentication教程时,我决定不安装Doctrine,因为我不打算通过安装symfony/orm-pack来使用it.Fixed它。