Reputation: 15
I'm trying to build my own MVC framework, but I'm having problems with the autoloader.
I have the following directory layout:
-application
--Model
---RegiserUser.php
--Libs
---Base.php
---Model.php
---Model
--Controller
---Login.php
Model_RegiserUser extends Model which extends Base
The autoloader method is in the base class. I'm trying to emulate the way you load classes in Zend:
protected function __autoload( $class_name )
{
echo 'test';
$filename = str_replace( '_', DIRECTORY_SEPARATOR, strtolower( $class_name ) ) . '.php';
$file = ROOT . $filename;
echo $file;
if( !file_exists( $file ) ) {
return FALSE;
}
include $file;
}
I'm getting this error:
Fatal error: Class 'Model_RegisterUser' not found in C:\EasyPHP\data\localweb\application\controller\Login.php on line 31
Upvotes: 0
Views: 71
Reputation: 104
strtolower is your problem... on a system like unix you try to load the file "registeruser.php" not "RegiserUser.php" (case sensitive ;))
Upvotes: 1