Autoloading with wildcards is not working in ConsoleCommand

Hi!

I am creating a testdrive application from scratch via console as descried here: http://www.yiiframework.com/doc/guide/1.1/en/quickstart.first-app

Then I change my config/console.php to:




return array(

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

	'name'=>'My Console Application',

	

	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

	),

	

	// application components

	'components'=>array(

		'db'=>array(

			'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',

		),

	),

);



I created a class in protected/models:




class Foo {

	

	public function foo() {

		echo "foo";

	}

}



My console command looks like that:




class FooCommand extends CConsoleCommand  {

	

	public function actionIndex() {

		$foo = new Foo();

		echo $foo->foo();

	}

	

}



Finally on my console I call:




yiic foo



And get:




Fatal error: Class 'Foo' not found in C:\ProgrammeNI\xampp2\htdocs\testdrive\pro

tected\commands\FooCommand.php on line 5


Call Stack:

    0.0008     323712   1. {main}() C:\ProgrammeNI\xampp2\htdocs\testdrive\prote

cted\yiic.php:0

    0.0017     334784   2. require_once('C:\ProgrammeNI\xampp2\htdocs\yii\framew

ork\yiic.php') C:\ProgrammeNI\xampp2\htdocs\testdrive\protected\yiic.php:7

    0.0197    1272456   3. CApplication->run() C:\ProgrammeNI\xampp2\htdocs\yii\

framework\yiic.php:33

    0.0197    1272456   4. CConsoleApplication->processRequest() C:\ProgrammeNI\

xampp2\htdocs\yii\framework\base\CApplication.php:158

    0.0197    1272456   5. CConsoleCommandRunner->run() C:\ProgrammeNI\xampp2\ht

docs\yii\framework\console\CConsoleApplication.php:88

    0.0222    1403352   6. CConsoleCommand->run() C:\ProgrammeNI\xampp2\htdocs\y

ii\framework\console\CConsoleCommandRunner.php:63

    0.0224    1404352   7. ReflectionMethod->invokeArgs() C:\ProgrammeNI\xampp2\

htdocs\yii\framework\console\CConsoleCommand.php:135

    0.0224    1404368   8. FooCommand->actionIndex() C:\ProgrammeNI\xampp2\htdoc

s\testdrive\protected\commands\FooCommand.php:0



The complete project is attached. Auto-loading works fine in my web applications.

Following lines added to FooCommand working as follows:




Yii::import('application.models.Foo'); //WORKS

Yii::import('application.models.*'); //FATAL ERROR



Why is the wildcard not working for my console?

I am using Xammp 1.74 with PHP 5.3.5 on Windows 7.

Furthermore I did some debugging in YiiBase::import() and the full path to proctected/models is actually added to the PHP include_path.

This is very strange!

I did a little more research and this is a workaround for me:




	public function run($args) {

		Yii::$enableIncludePath = false;

		parent::run($args);

	}



But I still don’t understand why


include('Foo.php');

fails when the include path to protected/models is set correctly (and works perfect on all CWebApplications).