Issues with console command.

I’m struggling with creating a simple console command. I created a new command class under protected/commands called sendEmail.php

sendEmail.php looks as follows

class sendEmailCommand extends CConsoleCommand{

    public function run($args){

        $arg1 = $args[0];

        $arg2 = $args[1];

        echo "Thanks for $arg1 and $arg2";



    public function getHelp(){ 

        return 'Usage: <toNumber> <Message>'; 



Now in /protected/config/console.php I have the following

return array(


	'name'=>'Email Application',


        // preloading 'log' component


	// autoloading model and component classes







	// application components



			// enable cookie-based authentication













			// use 'site/error' action to display errors













If I run the following command from the CLI within the protected folder

./yiic sendemail

I get the following error

./yiic sendemail e we

exception 'CException' with message 'sendEmail does not have a method named "run".' in .../base/CComponent.php:237

Stack trace:

I really do not know what could be wrong any advise will be appreciated.

I guess you have to rename the class to sendEmail (instead of sendEmailCommand).

What I though but in the documentation the Command needs to be included for any console commands?

Ok I thought this may not be the case if you use commandMap. Well rename the file to sendMailCommand.php and modify config accordingly. That’s the correct convention anyway.

Thanks, this worked :slight_smile: After changing it to sendMailCommand.php it worked, thanx for the tip. SOLVED