【问题标题】:Symfony2 crash after composer update作曲家更新后 Symfony2 崩溃
【发布时间】:2015-06-11 08:49:31
【问题描述】:

我遇到了一个问题,因为我在 Symfony2 安装上更新了我的供应商。

这是我的 composer.json 的内容:

{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
    "psr-0": { "": "src/" }
},
"require": {
    "php": ">=5.4",
    "symfony/symfony": ">=2.4",
    "doctrine/orm": "~2.2,>=2.2.3",
    "doctrine/doctrine-bundle": ">=1.2",
    "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": ">=3.0",
    "sensio/generator-bundle": ">=2.3",
    "incenteev/composer-parameter-handler": "~2.0",
    "white-october/pagerfanta-bundle": "dev-master",
    "friendsofsymfony/rest-bundle": "1.3.*",
    "friendsofsymfony/comment-bundle": "2.0.*@dev",
    "friendsofsymfony/message-bundle": "1.2.*@dev",
    "friendsofsymfony/user-bundle": "~2.0@dev",
    "nelmio/api-doc-bundle": "@stable",
     "ornicar/akismet-bundle": "dev-master",
    "friendsofsymfony/jsrouting-bundle": "2.0.*@dev",
    "appventus/alertify-bundle": "dev-master",
  "friendsofsymfony/oauth-server-bundle": "dev-master",
  "willdurand/propel-typehintable-behavior": "*",
  "hwi/oauth-bundle": "0.4.*@dev",
  "nomaya/social-bundle": "dev-master"

}
}

php composer.phar update 之后,当我尝试 /app.php 时,出现以下错误:

Deprecated: The Symfony\Component\Security\Core\SecurityContextInterface interface is deprecated since version 2.6 and will be removed in 3.0. in /var/www/html/xxx/app/cache/prod/classes.php on line 3035
Deprecated: The Symfony\Component\Security\Core\SecurityContext class is deprecated since version 2.6 and will be removed in 3.0. Use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage or Symfony\Component\Security\Core\Authorization\AuthorizationChecker instead. in /var/www/html/xxx/app/cache/prod/classes.php on line 3047
Fatal error: Uncaught exception 'Symfony\Component\Debug\Exception\ContextErrorException' with message 'Catchable 
Fatal Error: Argument 1 passed to Symfony\Component\Routing\Router::Symfony\Component\Routing\{closure}() must be an instance of Symfony\Component\Config\ConfigCacheInterface, instance of Symfony\Component\Config\ConfigCache given' in /var/www/html/xxx/app/cache/prod/classes.php:1302 

Stack trace: 
#0 /var/www/html/xxx/app/cache/prod/classes.php(1302): Symfony\Component\Debug\ErrorHandler->handleError(4096, 'Argument 1 pass...', '/var/www/html/p...', 1302, Array) 
#1 [internal function]: Symfony\Component\Routing\Router->Symfony\Component\Routing\{closure}(Object(Symfony\Component\Config\ConfigCache)) 
#2 /var/www/html/xxx/vendor/symfony/symfony/src/Symfony/Component/Config/ConfigCacheFactory.php(46): call_user_func(Object(Closure), Object(Symfony\Component\Config\ConfigCache)) 
#3 /var/www/html/xxx/app/cache/prod/classes.php(1313): Symfony\Component\Config\ConfigCacheFactory->cache('/var/ww in /var/www/html/xxx/app/cache/prod/classes.php on line 5261

当我去 /app_dev.php 我有这个:

Whoops, looks like something went wrong.

 1/1
 FatalErrorException in ConfigDataCollector.php line 276:
 Error: Undefined class constant 'END_OF_MAINTENANCE'

我的 PHP 版本是 Apache/2.2.15 上的 5.6.9。

有人知道吗?


谢谢 克努特

【问题讨论】:

标签: php symfony composer-php


【解决方案1】:

我通过重新生成 bootstrap.php.cache 解决了这个问题(通过运行 composer update / composer install,或直接通过脚本)

【讨论】:

  • 这为我解决了同样的问题。我使用以下内容重新创建 bootstrap.php.cache: php ./vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
【解决方案2】:

你可以试试这个:

php composer.phar self-update

之前

php composer.phar update

【讨论】:

    【解决方案3】:

    问题是我的不同供应商之间不兼容,我已将 composer.json 更新为:

    {
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/" }
    },
    "require": {
        "php": ">=5.4",
        "symfony/symfony": ">=2.4",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": ">=1.2",
        "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": ">=3.0",
        "sensio/generator-bundle": ">=2.3",
        "incenteev/composer-parameter-handler": "~2.0",
        "white-october/pagerfanta-bundle": "dev-master",
        "friendsofsymfony/rest-bundle": "1.3.*",
        "friendsofsymfony/comment-bundle": "2.0.*@dev",
        "friendsofsymfony/message-bundle": "1.2.*@dev",
        "friendsofsymfony/user-bundle": "~2.0@dev",
        "nelmio/api-doc-bundle": "@stable",
         "ornicar/akismet-bundle": "dev-master",
        "friendsofsymfony/jsrouting-bundle": "2.0.*@dev",
        "appventus/alertify-bundle": "dev-master",
      "friendsofsymfony/oauth-server-bundle": "dev-master",
      "willdurand/propel-typehintable-behavior": "*",
      "hwi/oauth-bundle": "0.4.*@dev",
      "nomaya/social-bundle": "dev-master"
    
    }
    }
    

    所有的作品......

    谢谢。

    【讨论】:

    • 此答案中的 composer.json 与发布的问题相同。你能指出变化吗?谢谢
    【解决方案4】:

    尝试:

    rm /var/www/html/xxx/app/cache/prod/* -rf
    

    【讨论】:

      【解决方案5】:

      不管怎样,我在升级 symfony(从 2.6 升级到 2.8)后遇到了这个问题,它在一个 vagrant guest 上运行。

      问题确实出在app/bootstrap.php.cache 文件上。在我们的例子中,它没有从我们的rsync 中排除,这意味着如果主机还没有更新composer,问题将会再次发生。它是通过在我们的 Vagrantfile 中从 rsync 中排除 bootstrap.php.cache 来解决的:

      config.vm.synced_folder "host/path", "guest/path", type: "rsync", rsync__exclude: [ 'bootstrap.php.cache'],

      此文件由composer 生成,因此在客户机上运行sudo composer installsudo composer update 将重新生成它。

      希望这可以节省其他人一些时间。

      【讨论】:

        猜你喜欢
        • 2016-09-21
        • 2017-01-20
        • 1970-01-01
        • 2015-12-01
        • 2015-09-11
        • 2016-03-22
        • 2014-09-07
        • 2016-09-06
        • 2021-08-07
        相关资源
        最近更新 更多