yiic not working with yiilite.php

I've created an application and changed my index.php like this (yii's parent dir is in my include_path):

$yii='yii-1.0.1/yiilite.php';


$config=dirname(__FILE__).'/protected/config/main.php';





// remove the following line when in production mode


defined('YII_DEBUG') or define('YII_DEBUG',true);





require_once($yii);


Yii::createWebApplication($config)->run();


When i try to call yiic shell i get this error:

Quote

Fatal error: Cannot redeclare class Yii in /usr/share/php/yii-1.0.1/yiilite.php on line 364

Everything works fine, if i use yii.php instead.

That's strange. I didn't see redeclaration of Yii in yiilite.php. Could you verify that? Maybe it is caused by your APC caching?

I disabled APC for the commandline now (and even restarted Apache just to make sure…). But still the same error. yiic gives me the help message, yiic shell produces the error.

If i get it right, yiic first includes yii.php and then the applications index.php in the "shell" command. In index.php there's a require_once(). So no problem if i also use yii.php in index.php: it will get included only once. Not so for yiilite.php.

ah, yes, that’s the cause of the issue (I won’t fix it though.  ;))

O.k. that means, we should always use yii.php in index.php when using yiic shell? Is there a reason why you include index.php instead of using the config file?

Because Yii doesn't enforce how to name the config file.

Actually, I think we can fix this issue by adding a class_exists check at the begin of yiilite.php.

Could you please create a ticket about this? Thanks.

Ok, created a ticket.

I know, this has been fixed. But there's still something strange happening here. I've an application created with yii-1.0.1.

  1. When i now switch to latest yii.php in index.php, i again get:

Quote

Fatal error: Cannot redeclare class Yii in /usr/share/php/yii-svn/yii.php on line 29

It works, when using yii.php from 1.0.1 in index.php.

  1. I've changed the accessRules for my default controller, to not allow anything for guest users (it's a private site, with access only for logged in users):
<?php


    public function accessRules()


    {


        return array(


            // Deny guests from everything


            array('deny', 'users'=>array('?'))


        );


    }


Now whenever i want to start yiic shell, nothing happens (script exits without message, i'm back at the command prompt).

Any idea?

  1. Check your protected/yiic and see if it is including the right file (since you switch to use a new version of yii)

  2. That's expected…i'm developing a web-based yiic tool which should solve this problem completely.

Ok, thanks.

You where right with 1: Indeed it was a problem with yiic from the wrong version. I have a symlink to yiic (1.0.1) to /usr/bin. When using the original yiic from svn it works again.