Cconsoleapplication Read Command From Different Locations

Hi:

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?

Thanks

Luis

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:




<?php


// This is the configuration for yiic console application.

// Any writable CConsoleApplication properties can be configured here.

return array(

	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

	

	'commandMap' => array(

		'test' => array(

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

		)

	),

...



  • And call command: yiic test