我最近在我的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"
}
}
}
预先感谢您的帮助 .
2 回答
这一直是今天发生的事情 . (我在Symfony 2.8.17上 . )将Swiftmailer软件包恢复到版本2.4,为我修复了这个问题 .
在 composer.json 文件中更改
至
现在做一个作曲家更新,所以你回到Swiftmailer包的2.4版本,一切都应该很好 . 看起来2.5更新中有一个错误 .
如果您仍然遇到问题,请尝试使用以下命令完全清除缓存:
还要检查 composer.lock 文件以确保Swiftmailer软件包确实已恢复为2.4 . 您应该看到这样的部分:
您描述的问题很可能不是由错误引起的,而是由相关依赖项更改为
swiftmailer/swiftmailer
.You have requested a non-existent service "mail".
表示缺少服务mail
,Unable to replace alias "swiftmailer.mailer.default.transport.real" with actual definition "mail".
是一个广泛的提示,这与swfitmailer transportmail
,类Swift_Transport_MailTransport
使用insecure php mail() function有关 . 出于安全原因,此运输是deprecated since swiftmailer version 5.4.5 .为了解决问题,您需要
从传输
mail
切换到当前swiftmailer支持的传输,或将
"swiftmailer/swiftmailer": "<6.0"
添加到您的composer.json依赖项中,以防止软件包安装swiftmailer v6.x,其中Swift_Transport_MailTransport
已消失 . 不幸的是,symfony/swiftmailer-bundle
需要从v3.0.0开始的swiftmailer v6.x,所以你需要"symfony/swiftmailer-bundle": "^2"