Yii Can't Include Files

When I run the command yiic test test, I get the following error and backtrace:

PHP Error[2]: include(Test.php): failed to open stream: No such file or directory

    in file /var/www/yii/framework/YiiBase.php at line 421

#0 /var/www/yii/framework/YiiBase.php(421): autoload()

#1 unknown(0): autoload()

#2 /var/www/inviso/protected/commands/TestCommand.php(4): spl_autoload_call()

#3 unknown(0): TestCommand->actionTest()

#4 /var/www/yii/framework/console/CConsoleCommand.php(172): ReflectionMethod->invokeArgs()

#5 /var/www/yii/framework/console/CConsoleCommandRunner.php(67): TestCommand->run()

#6 /var/www/yii/framework/console/CConsoleApplication.php(91): CConsoleCommandRunner->run()

#7 /var/www/yii/framework/base/CApplication.php(169): CConsoleApplication->processRequest()

#8 /var/www/yii/framework/yiic.php(33): CConsoleApplication->run()

#9 /var/www/inviso/protected/yiic.php(7): require_once()

#10 /var/www/inviso/protected/yiic(4): require_once()

The TestCommand.php (located in protected/commands/) file looks like this:


class TestCommand extends CConsoleCommand {

  public function actionTest() {

    $test = new Test;


And my Test.php (located in protected/components/) file looks like this:


class Test {


My config has these lines:





What’s causing the problem?

Try placing TestCommand.php in protected/commands instead of /commands.

Sorry, that’s what I meant. I’ve updated my post to say that, but the path has always been correct in the stacktrace.

I have no idea what’s going on. I just made a new project and made a console command that created a new Controller (which is already created by default) and I get the same error…

The issue was I didn’t have the autoload paths set in protected/config/console.php. I didn’t realize that webapps had a different config file than console apps.