Problem with model case when uploading to server

Hello everyone.

It seems that my server is case sensitive, because in my Mac (using XAMPP) I don’t have this problem.

When I uploaded my project for the first time to my production server, I get this error:




PHP Error


Description


include(usuario.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory


Source File


/home/vendomic/yii/framework/YiiBase.php(324)


00312:      * @param string class name

00313:      * @return boolean whether the class has been loaded successfully

00314:      */

00315:     public static function autoload($className)

00316:     {

00317:         // use include so that the error PHP file may appear

00318:         if(isset(self::$_coreClasses[$className]))

00319:             include(YII_PATH.self::$_coreClasses[$className]);

00320:         else if(isset(self::$_classes[$className]))

00321:             include(self::$_classes[$className]);

00322:         else

00323:         {

00324:             include($className.'.php');

00325:             return class_exists($className,false) || interface_exists($className,false);

00326:         }

00327:         return true;

00328:     }

00329: 

00330:     /**

00331:      * Writes a trace message.

00332:      * This method will only log a message when the application is in debug mode.

00333:      * @param string message to be logged

00334:      * @param string category of the message

00335:      * @see log

00336:      */

Stack Trace


#0 /home/vendomic/yii/framework/YiiBase.php(324): autoload()

#1 unknown(0): autoload()

#2 /home/vendomic/public_html/vmc/protected/controllers/UsuarioController.php(72): spl_autoload_call()

#3 /home/vendomic/yii/framework/web/actions/CInlineAction.php(32): UsuarioController->actionCreate()

#4 /home/vendomic/yii/framework/web/CController.php(300): CInlineAction->run()

#5 /home/vendomic/yii/framework/web/filters/CFilterChain.php(129): UsuarioController->runAction()

#6 /home/vendomic/yii/framework/web/filters/CFilter.php(41): CFilterChain->run()

#7 /home/vendomic/yii/framework/web/CController.php(957): CAccessControlFilter->filter()

#8 /home/vendomic/yii/framework/web/filters/CInlineFilter.php(59): UsuarioController->filterAccessControl()

#9 /home/vendomic/yii/framework/web/filters/CFilterChain.php(126): CInlineFilter->filter()

#10 /home/vendomic/yii/framework/web/CController.php(283): CFilterChain->run()

#11 /home/vendomic/yii/framework/web/CController.php(257): UsuarioController->runActionWithFilters()

#12 /home/vendomic/yii/framework/web/CWebApplication.php(332): UsuarioController->run()

#13 /home/vendomic/yii/framework/web/CWebApplication.php(120): CWebApplication->runController()

#14 /home/vendomic/yii/framework/base/CApplication.php(135): CWebApplication->processRequest()

#15 /home/vendomic/public_html/vmc/index.php(11): CWebApplication->run()



In the description part, you can see that include usuario.php does not exist.

If I change the model file name, from Usuarios to usuarios, it works, but then on some other action, I get a similar error but saying that "usuarios" does not exist.

How can I fix this?

Thanks

The key is consistency.

if the file is named file.php then call it as file.php, if the file is File.php, refer to it as File.php, same for variables and such. Do that and you will not have that problem.

Found it.

The consistency problem was when defining relations: when naming the model, it should have the same case as the file.

usuarios.php = usuarios

Usuarios.php = Usuarios