2017-03-01 175 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"