我是symfony的初學者。當我在交響樂中呼叫 get API 時,顯示如下錯誤。
RuntimeException
HTTP 500 Internal Server Error
Could not resolve argument $salesteamRepository of "App\Controller\SalesController::index()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?
uj5u.com熱心網友回復:
這取決于你的 symfony 版本。在版本 6(可能還有 5.4)中,除了 autowire: true 和 autoconfigure: true 之外,您不需要任何額外的配置。
在舊版本中,您必須告訴框架將您的控制器視為具有方法自動裝配的控制器:
# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
https://symfony.com/doc/current/controller/service.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/432279.html
