What I do wrong in my cli command file?
thrown error when try to clean cache like this "There are no commands defined in the "cache" namespace."
class Hicustomer extends Command
{
protected $myblockobject;
public function __construct(\Vendor\Extension\Block\Mycustomblock $myblockobject)
{
$this->myblockobject = $myblockobject;
parent::__construct();
}
protected function configure()
{
$this->setName('cloudways:hicustomer');
$this->setDescription('Demo command line');
parent::configure();
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$myblockobject = $this->myblockobject->create()->MyCustomFunction();
$output->writeln("Hi Customer");
}
}
Best Answer
"There are no commands defined in the "cache" namespace."
This makes me think the issue is above your CLI command.
Make sure magento command are properly installed do
bin/magento list
in the first place and see if the command doesn't fail, if cache:clean is available and if your new command is available too.My guess is that one of these steps will fail.May be you will be provided more information from
var/log/exception.log
and/orvar/log/system.log