Reputation: 5162
I do have simple command with constructor requiring LoggerInterface
as dependency.
<?php
namespace App\Command;
// use (...)
class ProcessReportCommand extends Command
{
/** @var LoggerInterface */
private $logger;
public function __construct(LoggerInterface $logger)
{
parent::__construct();
$this->logger = $logger;
}
// (...)
}
My configuration in services.yml
looks pretty default:
parameters:
services:
_defaults:
autowire: true
autoconfigure: true
public: false
App\:
resource: '../src/*'
exclude: '../src/{Entity,Migrations,Exception,Tests,Kernel.php}'
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
Unfortunately I am getting PHP Error saying that dependency was not injected.
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Too few arguments to function App\Command\ProcessReportCommand::__construct(), 0 passed in /home/tomasz/project/bin/console on line 40 and exactly 1 expected in /home/tomasz/project/src/Command/ProcessReportCommand.php:17
Even if I will switch this dependency to any other class which I have under App\
it behaves always like that.
I literally have no idea what should I do more to make it works, all ways even the one with including explicitly the service inside services.yml
does not work for me. Any clues?
Upvotes: 3
Views: 9239