I'm trying to figure out why I am getting this error for the first command I've written specifically for Symfony5:
There are no commands defined in the "hitachi" namespace.
Auto-wiring is on:
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App:
resource: '../src/'
exclude:
- '../src/DependencyInjection/'
- '../src/Entity/'
- '../src/Kernel.php'
- '../src/Tests/'
I meticulously followed the docs. The $defaultName
is defined. The proper Command
class is extended and the constructor overridden for service injection.
namespace IAMDataProcessingBundleCommand;
use IAMDataProcessingBundleServiceHitachiMobileUpdaterService;
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputInterface;
use SymfonyComponentConsoleOutputOutputInterface;
class HitachiMobileUpdaterCommand extends Command
{
protected static $defaultName = 'hitachi:mobileupdate';
protected $hitachiMobileUpdaterService;
public function __construct(HitachiMobileUpdaterService $hitachiMobileUpdaterService)
{
$this->hitachiMobileUpdaterService = $hitachiMobileUpdaterService;
parent::__construct();
}
protected function configure()
{
$this
->setDescription('Update the HitachiId User record mobile field with the first active mobile phone found in Duo.')
;
}
I have tried to go around the auto-wiring and configured the command with <bundle-top>/Resources/config/services.yaml
, but it did not help and the error remained the same.
hitachi_mobule_updater_command:
public: true
class: IAMDataProcessingBundleCommandHitachiMobileUpdaterCommand
arguments:
- "@hitachi_mobile_updater_service"
tags:
- {name: 'console.command', command: 'hitachi:mobileupdate'}
question from:
https://stackoverflow.com/questions/65912114/symfony-5-not-finding-commands-in-a-given-namespace 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…