Cconsoleapplication Read Command From Different Locations


we are working in a YII app that will go to have a lot of CConsoleCommand, Yii by default use the path "protected/commands" but we want to create subfolders inside the "protected/commands" to organize our CConsoleCommand.

How I can do this?



Hi !

You can uses subfolde for your command, but you must map command. Example i have TestCommand in example subfolder of commands:

  • protected/commands/example/TestCommand.php

  • Map command in console.php config uses:


// This is the configuration for yiic console application.

// Any writable CConsoleApplication properties can be configured here.

return array(



	'commandMap' => array(

		'test' => array(

			'class' => 'application.commands.example.TestCommand'




  • And call command: yiic test