1
當我有在Symfony3依賴注射的一個問題:錯誤注入教義和定製服務
這是我services.yml
some_service:
class: StagingBundle\Service\SomeService
arguments: ['@doctrine']
arguments: ['@test.other_service']
這是SomeService.php
public function __construct($doctrine, SomeService $someService)
{
$this->doctrine=$doctrine;
$this->someService=$someService;
}
的構造
運行我的控制檯命令時出現以下錯誤:
[Symfony\Component\Debug\Exception\ContextErrorException]
Catchable Fatal Error: Argument 2 passed to stagingBundle\Service\SomeService::__construct() must be an instance of StagingBundle\Service\OtherService, none given, called in /var/www/projects/myApp/var/cache/dev/appDevDebugProjectContainer.php on line 1141 and defined
爲什麼會發生這種情況,我該如何解決?
謝謝:) :) :) – Nathan