ballhogjoni Posted June 17, 2012 Share Posted June 17, 2012 This is so weird ... the class does exist. In my index.php I am calling this line of code and this is the line that is throwing the error: $router = new Sname_Router(); I am using a custom __autoload method and I am defining that function in index.php. Here it is function __autoload($class_name) { require_once APPLICATION_PATH . '/../libraries/Sname/Autoloader.php'; //Check to see if the class is in the app directory $loaded = Sname_Autoloader::loadClass($class_name, array(APPLICATION_PATH . "/controllers/", APPLICATION_PATH . "/models/", APPLICATION_PATH . "/helpers/")); //Check to see if the class is in the libraries if (!$loaded) $loaded = Sname_Autoloader::loadClass($class_name, APPLICATION_PATH . '/../libraries/'); //Check to see if the class is in active record if (!$loaded) { require_once APPLICATION_PATH . '/../libraries/activerecord/ActiveRecord.php'; activerecord_autoload($class_name); } //Check to see if the class is in the include path if (!$loaded) { Sname_Autoloader::loadClass($class_name, explode(PATH_SEPARATOR, get_include_path())); } } App directory structure sname-git - app -- controllers -- models -- helpers -- views -libraries --Sname ---Router.php --activerecord The Sname_Router class is located here /Users/myname/dev/git/sname-git/libraries/Sname/Router.php. I have checked to make sure that this is the correct location. This is the first few lines of my Router.php <?php class Sname_Router { ... What's going on? Any help would be much appreciated! Link to comment https://forums.phpfreaks.com/topic/264318-fatal-error-class-sname_router-not-found-in/ Share on other sites More sharing options...
ballhogjoni Posted June 17, 2012 Author Share Posted June 17, 2012 ok fixed it ... i hate trying to figure out the problem for hours and then writing up a post and then fixing the problem a minute later. In my Sname_Autoloader::loadClass method I had the following code if (!file_exists($file)) return false; I didn't realize file_exists was returning null so the method was always returning false. I changed that code to if (file_exists($file) === null) return false; and it works perfect! Link to comment https://forums.phpfreaks.com/topic/264318-fatal-error-class-sname_router-not-found-in/#findComment-1354542 Share on other sites More sharing options...
xyph Posted June 17, 2012 Share Posted June 17, 2012 File exists will return true/false, according to the manual. You seem to be bypassing the check completely, rather than fixing it. Link to comment https://forums.phpfreaks.com/topic/264318-fatal-error-class-sname_router-not-found-in/#findComment-1354560 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.