Monday, July 8, 2013

Alias "{alias}" is invalid. Make sure it points to an existing PHP file and the file is readable.

The following error occur on my Yii web app
Alias "ext.dropdown.DropDownBox" is not valid.  Make sure it points to an existing PHP file and the file is readable.
I have checked that all of the permission is readable. This error only occurs in production and not in our test environment (mac and windows).
It turns out that our prod environment is using Centos and in my code I call
"$this->widget('ext.dropdown.DropDownBox', array(..." which should have been
"$this->widget('ext.dropDown.DropDownBox', array(..." 
Centos is very strict on case sensitivity. My extension folder name is with capital D "dropDown" and therefore I should have called the extension with capital D. 
D:\xampp\YII\framework\YiiBase.php(316)
304         if($isClass && (class_exists($className,false) || interface_exists($className,false)))
305             return self::$_imports[$alias]=$className;
306 
307         if(($path=self::getPathOfAlias($alias))!==false)
308         {
309             if($isClass)
310             {
311                 if($forceInclude)
312                 {
313                     if(is_file($path.'.php'))
314                         require($path.'.php');
315                     else
316                         throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing PHP file and the file is readable.',array('{alias}'=>$alias)));
317                     self::$_imports[$alias]=$className;
318                 }
319                 else
320                     self::$classMap[$className]=$path.'.php';
321                 return $className;
322             }
323             else  // a directory
324             {
325                 if(self::$_includePaths===null)
326                 {
327                     self::$_includePaths=array_unique(explode(PATH_SEPARATOR,get_include_path()));
328                     if(($pos=array_search('.',self::$_includePaths,true))!==false)

6 comments:

  1. thanks alot...this saves me alot of time!

    ReplyDelete
  2. Thanks...I did not think that Centos and ubuntu can have a different setting

    ReplyDelete
  3. Thanks a lot! it really helped me...

    ReplyDelete
  4. thanks, this solved my problem as well

    ReplyDelete
  5. Thanks for suggest the solutions.

    ReplyDelete