symfony service Передача параметров сервиса в yaml файле: must be null, an instance of..., you should configure its value
Primary tabs
Проблема с передачей параметров пользовательскому сервису в sumfony 4:
Invalid service the value of argument "..." of method "...::__construct()" must be null, an instance of Symfony\Component\DependencyInjection\Reference or an instance of Symfony\Component\DependencyInjection\Definition, string given.
Переделал с
App\Service\VkAPIClientService: arguments: accountId: '12345928' apiVersion: 5.95 accessToken: 5b4e5ba716cb75bdad68345
на:
App\Service\VkAPIClientService: arguments: $accountId: '12345928' $apiVersion: 5.95 $accessToken: 5b4e5ba716cb75bdad68345
После чего получаем ошибку:
Cannot autowire service "......": argument "$accountId" of method "__construct()" is type-hinted "string", you should configure its value explicitly.
но тут уже проблема оказалась просто в том, что в ямле имя класса написано было App\Service\VkAPIClientService, а в коде оно же присутствовало частично с другим регистром, а именно:
App\Service\VkApiClientService
- т.е. убедитесь что в yaml вы указываете именно тот класс сервиса, что реально существует (что имя класса верно).
ВНИМАНИЕ: секретные значения лучше хранить в игнорируемом файле так.
- Log in to post comments
- 2746 reads