使用composer.phar update将symfony / swiftmailer-bundle更新为v2.2.5后,我收到了这样的错误:
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing symfony/swiftmailer-bundle (v2.2.4)
- Installing symfony/swiftmailer-bundle (v2.2.5)
Loading from cache
Writing lock file
Generating autoload files
[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
The service definition "swiftmailer.mailer" does not exist.
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
降级到2.2.4后问题得到解决
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing symfony/swiftmailer-bundle (v2.2.5)
- Installing symfony/swiftmailer-bundle (v2.2.4)
Loading from cache
Writing lock file
Generating autoload files
Clearing the cache for the dev environment with debug true
Installing assets using the hard copy option
Installing assets (part of code removed)
答案 0 :(得分:1)
您绝对应该使用mailer
服务,因为它是正确的swiftmailer服务的别名,无论它如何命名。例如im v2.3.3,它是swiftmailer.mailer.default
但你必须使用
$container->findDefinition('mailer');
与getDefinition()
不同的也会解析别名,因此如果
$serviceId
参数是别名,您将获得基础定义。
答案 1 :(得分:0)
触发错误的行是:
$definition = $container->getDefinition('swiftmailer.mailer') ;
错误是由更改服务名称引起的。直到2.2.4这个名字是
swiftmailer.mailer
从2.2.5开始是:
swiftmailer.mailer.abstract
我将行改为:
$definition = $container->hasDefinition('swiftmailer.mailer') ? $container->getDefinition('swiftmailer.mailer') : $container->getDefinition('swiftmailer.mailer.abstract');
修正了错误。