phpignorant Posted June 20, 2011 Share Posted June 20, 2011 Hi , I am trying to modify some open source code . I create an index.php file and I am just trying to instantiate some classes in there . So what I have is some directory like root/dir1/dir2/SomeClass.php and from root/index.php i try new SomeClass() , but I get class not found . I tried doing an include but the problem just seems to cascade onto the next file , like some class in SomeClass.php is then also not found . The paths look correct to me . Anyone know what this is about ? Quote Link to comment https://forums.phpfreaks.com/topic/239836-class-not-found/ Share on other sites More sharing options...
trq Posted June 20, 2011 Share Posted June 20, 2011 Anyone know what this is about ? Yes. You need to make sure all classes are included properly. Quote Link to comment https://forums.phpfreaks.com/topic/239836-class-not-found/#findComment-1232036 Share on other sites More sharing options...
phpignorant Posted June 20, 2011 Author Share Posted June 20, 2011 I can fix my reference to SomeClass() with an include . The problem is now other references inside SomeClass() are broken for some reason . I didn't create SomeClass() . It and the other files already came together so I am puzzled by why all the references are broken now ... I get error that says reference inside SomeClass() called SomeInterface() can't be found and I check the path and it is fine . Is there some project settings I need to do ? Or do i need to make an include inside index.php for every single file in the project ? I figured if I included SomeClass.php and SomeClass.php includes the files it needs , that should be the end of the matter . There are a probably 100 or more directories and files there . That is too many ; there must be an easier way . I am lost on what is going on here . Quote Link to comment https://forums.phpfreaks.com/topic/239836-class-not-found/#findComment-1232051 Share on other sites More sharing options...
trq Posted June 20, 2011 Share Posted June 20, 2011 Without knowing what code it is you downloaded it's pretty hard to help. If it's a framework of some sort you can likely just put it on your include_path and use an auto loader of some sort. Have you tried looking through the documentation for clues? Quote Link to comment https://forums.phpfreaks.com/topic/239836-class-not-found/#findComment-1232105 Share on other sites More sharing options...
phpignorant Posted June 20, 2011 Author Share Posted June 20, 2011 Well , here is the exact error I get when I call MManager.php ( i fixed the reference to MManager.php ) . The path to Kernel.php looks good unless those need to be backslashes not forward slashes ? error Warning: require_once(root/system/kernel/Kernel.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\LDAP_import\root\system\services\MManager.php on line 81 Fatal error: require_once() [function.require]: Failed opening required 'root/system/kernel/Kernel.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\LDAP_import\root\system\bootstrap\MManager.php on line 81 Quote Link to comment https://forums.phpfreaks.com/topic/239836-class-not-found/#findComment-1232336 Share on other sites More sharing options...
phpignorant Posted June 20, 2011 Author Share Posted June 20, 2011 OK , i think I get it ; those need to be absolute paths ... i will look into this include_path thing to see if that will resolve ; thanks . Quote Link to comment https://forums.phpfreaks.com/topic/239836-class-not-found/#findComment-1232337 Share on other sites More sharing options...
phpignorant Posted June 20, 2011 Author Share Posted June 20, 2011 Yes , it was the include_path in php.ini . I recreated the project in NetBeans though and everything is working now without anything in the include_path so overall not sure what happened ; something to do with the IDE . You can mark this solved . Quote Link to comment https://forums.phpfreaks.com/topic/239836-class-not-found/#findComment-1232526 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.