0

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");
        }
    }
1
  • you need to first confirm : \Vendor\Extension\Block\Mycustombloc this file is available and also this function MyCustomFunction(). Into this one you need to replace your orignal block file path and function name. Oct 13 at 4:46
0

"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

1
0
<?php

namespace Vendor\Module\Console;


use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use \Vendor\Module\Helper\Data;

class Hicustomer extends Command
{
   
    
    public function __construct(Data $helper)
    {
            $this->helper = $helper;
            parent::__construct();
    }
    
    protected function configure()
    {
        $this->setName('cloudways:hicustomer');
        $this->setDescription('Demo command line');
        parent::configure();
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
       
        $this->helper->checkImage();
      
        $output->writeln("Hi Customer");
    }
}
1
  • Change only \Vendor\Module names and try. Works for me)
    – NoOn
    Oct 15 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.