Jump to content

class not found


phpignorant

Recommended Posts

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 ?

Link to comment
Share on other sites

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 .

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 .

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.