Reputation: 410
I have a problem with dependencies injections in Symfony3:
This is my services.yml
some_service:
class: StagingBundle\Service\SomeService
arguments: ['@doctrine']
arguments: ['@test.other_service']
This is the constructor of SomeService.php
public function __construct($doctrine, SomeService $someService)
{
$this->doctrine=$doctrine;
$this->someService=$someService;
}
When running my console command I get the following error:
[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
Why does this happen and how can I solve it?
Upvotes: 1
Views: 39
Reputation: 2295
"arguments" is an array and can only be there once, so it should look like this
some_service:
class: StagingBundle\Service\SomeService
arguments: ['@doctrine', '@test.other_service']
Upvotes: 2