2017-03-01 171 views
1

我最近在我的Symfony应用程序(2.7)上作了一个作曲家更新。由于我做了这个更新,swiftmailer从2.4变为2.5,并且在命令之后,控制台向我显示了这个错误: [RuntimeException]作曲家更新后出错

执行“'cache时发生错误:clear --no-warmup'”命令:

[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException] 

Unable to replace alias "swiftmailer.mailer.default.transport.real" with actual definition "mail". 

[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException] 

You have requested a non-existent service "mail". 

我试图删除“供应商”中的swiftmailer目录,但它没有奏效。 这里是我的composer.json:

{ 
"name": "symfony/framework-standard-edition", 
"license": "MIT", 
"type": "project", 
"description": "The \"Symfony Standard Edition\" distribution", 
"autoload": { 
    "psr-4": { "": "src/" } 
}, 
"require": { 
    "php": ">=5.3.9", 
    "symfony/symfony": "2.7.*", 
    "doctrine/orm": "^2.4.8", 
    "doctrine/doctrine-bundle": "~1.4", 
    "symfony/assetic-bundle": "~2.3", 
    "symfony/swiftmailer-bundle": "~2.3", 
    "symfony/monolog-bundle": "~2.4", 
    "sensio/distribution-bundle": "~4.0", 
    "sensio/framework-extra-bundle": "^3.0.2", 
    "incenteev/composer-parameter-handler": "~2.0", 
    "friendsofsymfony/user-bundle": "dev-master" 
}, 
"require-dev": { 
    "sensio/generator-bundle": "~2.3", 
    "symfony/phpunit-bridge": "~2.7" 
}, 
"scripts": { 
    "symfony-scripts": [ 
     "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", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget" 
    ], 
    "post-install-cmd": [ 
     "@symfony-scripts" 
    ], 
    "post-update-cmd": [ 
     "@symfony-scripts" 
    ] 
}, 
"config": { 
    "bin-dir": "bin", 
    "platform": { 
     "php": "7.0" 
    } 
}, 
"extra": { 
    "symfony-app-dir": "app", 
    "symfony-web-dir": "web", 
    "symfony-assets-install": "relative", 
    "incenteev-parameters": { 
     "file": "app/config/parameters.yml" 
    }, 
    "branch-alias": { 
     "dev-master": "2.7-dev" 
    } 
} 

}

预先感谢您的帮助。

+0

最后使它重新安装swiftmailer束2.4,但问题是永远存在的。请帮助 ! –

+1

从今天起,这绝对已经开始发生。 (Symfony 2.8在这里。) - 编辑:找到原因,见下面的答案。 – Adambean

回答

1

从今天起,这一直发生。 (我在Symfony 2.8.17上。)将Swiftmailer软件包恢复到2.4版已经为我解决了这个问题。

在你composer.json文件更改

"symfony/swiftmailer-bundle": "~2.3", 

"symfony/swiftmailer-bundle": "2.4", 

现在做一个作曲家更新,所以你回去Swiftmailer包的2.4版,所有应该很好。看起来在2.5更新中有一个错误。

-

如果您还有问题,请尝试以下命令来充分冲洗掉缓存:

rm -rf app/cache/* 
rm app/bootstrap.php.cache 

还要检查你的composer.lock文件,以确保Swiftmailer包真的有恢复到2.4。你应该看到这样一段:

{ 
     "name": "symfony/swiftmailer-bundle", 
     "version": "v2.4.2", 
     "source": { 
      "type": "git", 
      "url": "https://github.com/symfony/swiftmailer-bundle.git", 
      "reference": "ad751095576ce0c12a284e30e3fff80c91f27225" 
     }, 
     "dist": { 
      "type": "zip", 
      "url": "https://api.github.com/repos/symfony/swiftmailer-bundle/zipball/ad751095576ce0c12a284e30e3fff80c91f27225", 
      "reference": "ad751095576ce0c12a284e30e3fff80c91f27225", 
      "shasum": "" 
     }, 
     "require": { 
      "php": ">=5.3.2", 
      "swiftmailer/swiftmailer": ">=4.2.0,~5.0", 
      "symfony/config": "~2.7|~3.0", 
      "symfony/dependency-injection": "~2.7|~3.0", 
      "symfony/http-kernel": "~2.7|~3.0" 
     }, 
     "require-dev": { 
      "symfony/console": "~2.7|~3.0", 
      "symfony/framework-bundle": "~2.7|~3.0", 
      "symfony/phpunit-bridge": "~2.7|~3.0", 
      "symfony/yaml": "~2.7|~3.0" 
     }, 
     "suggest": { 
      "psr/log": "Allows logging" 
     }, 
     "type": "symfony-bundle", 
     "extra": { 
      "branch-alias": { 
       "dev-master": "2.4-dev" 
      } 
     }, 
     "autoload": { 
      "psr-4": { 
       "Symfony\\Bundle\\SwiftmailerBundle\\": "" 
      } 
     }, 
     "notification-url": "https://packagist.org/downloads/", 
     "license": [ 
      "MIT" 
     ], 
     "authors": [ 
      { 
       "name": "Symfony Community", 
       "homepage": "http://symfony.com/contributors" 
      }, 
      { 
       "name": "Fabien Potencier", 
       "email": "[email protected]" 
      } 
     ], 
     "description": "Symfony SwiftmailerBundle", 
     "homepage": "http://symfony.com", 
     "time": "2016-12-20T04:44:33+00:00" 
    }, 
+0

嗨,thx为您的答案。 我做了你所说的,但它没有改变。我已经在2.4.0中重新安装了swiftmailer-bundle,但没有解决问题。我手动清除缓存,以确保问题仍然存在。 –

+1

您是否也删除了“bootstrap.php.cache”文件? – Adambean

+0

我没有,再次尝试,它的工作。上次我修改了composer.lock中的swiftmailer-bundle版本而不是composer.json,可能是这个原因。顺便说一句,我爱你男人thx! ^^ –

1

最有可能你所描述的问题不是由错误造成的,而是通过改变相关的依赖关系swiftmailer/swiftmailer

You have requested a non-existent service "mail".说,一个服务mail缺失,​​是一个广义的暗示,这是swfitmailer运输mail,使用类Swift_Transport_MailTransport有关。出于安全原因,此传输是deprecated since swiftmailer version 5.4.5

为了解决这个问题,就需要

  • 开关从运输mail由当前swiftmailer支持的传输,或
  • 为了防止包从添加"swiftmailer/swiftmailer": "<6.0"您composer.json依赖安装swiftmailer v6.x,其中Swift_Transport_MailTransport不见了。不幸的是,symfony/swiftmailer-bundle需要swiftmailer 6.x版V3.0.0从开始,所以你需要要求"symfony/swiftmailer-bundle": "^2"