Magento 2 CLI Error – Custom File Function Call Issue

clierrormagento2

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/or var/log/system.log

Related Topic