NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
[resolved] Undefined class controller


Joined: 19 Nov 2007
Posts: 7
Reply with quote
Hi,

I just installed PhpEd and tried to debug my CodeIgniter application. I opened one of my Blog.php controller class and hit F9. The debugger then pops up the following error message:
Quote:

Error:E_ERROR
Class blog: Cannot inherit from undefined class controller at Blog.php line 8



Any sort of help would be appreciated.

Thanks
View user's profileFind all posts by DsyfaSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
Did you start debugging from that file? If you haven't specified a default file to run in the project properties it will attempt to execute the file that is currently opened (& selected)
As you don't have any includes/requires before the class definition the error is exactly what it says. The controller class isn't known and thus it's impossible to inherit from.
Setting a file to run or opening the file you want to start debugging from should solve the issue I think
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 19 Nov 2007
Posts: 7
Reply with quote
Blizz wrote:
Did you start debugging from that file? If you haven't specified a default file to run in the project properties it will attempt to execute the file that is currently opened (& selected)
As you don't have any includes/requires before the class definition the error is exactly what it says. The controller class isn't known and thus it's impossible to inherit from.
Setting a file to run or opening the file you want to start debugging from should solve the issue I think

Ok.. when I start debugging from index.php, the debugging goes smoothly. But the debugger reaches my controller class after ages!! It goes through lots of library classes and CI base classes and then reaches my controller class. Is there a way to directly jump to my controller and auto include all the necessary base classes before hand?
View user's profileFind all posts by DsyfaSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
If you have the "stop on the 1st line enabled" (which it is by default), start a debug session as normal (F9 or the play button with the D on).
You'll see blue dots in front of the lines that contain executable code.
Open your Blog-class file and click in the ruler on the line number of the line you wish to stop on, normally the line will
turn red to indicate it is a breakpoint. Then press the debug button (or F9) again to start running the code, it should stop on the indicated line.
I prefer setting the breakpoint after the debug-session started, but you can set it in advance as well.

What also is a handy thing is the DebugBreak() function. Put that line anywhere in your code and then browse the site normally with a browser (or debug it).
When one of those function calls is encountered a debug session will be triggered automatically (or an existing session will break/stop like a normal breakpoint).

I usually put those lines in areas that should never get executed under normal circumstances. Watch out with this approach though, if you forget to remove them when you upload the files to your production environment they will break your program. If you don't have the debugger module included (as usually is the case on a production server), the function is unknown!
I usually add this kind of extra code in my production file:
Code:

if ( ! function_exists ( 'DebugBreak' ) )
{
   function DebugBreak ( )
   {
       // Do action (mail or something)
   }
}
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 19 Nov 2007
Posts: 7
Reply with quote
Blizz wrote:
If you have the "stop on the 1st line enabled" (which it is by default), start a debug session as normal (F9 or the play button with the D on).
You'll see blue dots in front of the lines that contain executable code.
Open your Blog-class file and click in the ruler on the line number of the line you wish to stop on, normally the line will
turn red to indicate it is a breakpoint. Then press the debug button (or F9) again to start running the code, it should stop on the indicated line.
I prefer setting the breakpoint after the debug-session started, but you can set it in advance as well.

What also is a handy thing is the DebugBreak() function. Put that line anywhere in your code and then browse the site normally with a browser (or debug it).
When one of those function calls is encountered a debug session will be triggered automatically (or an existing session will break/stop like a normal breakpoint).

I usually put those lines in areas that should never get executed under normal circumstances. Watch out with this approach though, if you forget to remove them when you upload the files to your production environment they will break your program. If you don't have the debugger module included (as usually is the case on a production server), the function is unknown!
I usually add this kind of extra code in my production file:
Code:

if ( ! function_exists ( 'DebugBreak' ) )
{
   function DebugBreak ( )
   {
       // Do action (mail or something)
   }
}


Ok... I followed your steps. The debugger doesn't stop at the breakpoint. Sad When I press F9 the second time, the output tab opens up -> I navigate to the function where the breakpoint is set for e.g. http://localhost/myapp/Blog/login, where 'Blog' is the controller and 'login' is a function and the breakpoint is set inside the login function.

Any idea wats goin on??
View user's profileFind all posts by DsyfaSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
If you set a breakpoint on a non executable line (like on a function definition) it will be moved to the first line that can be executed. So make sure that you set it on an actual piece of code, not on a class or function statement.

You might want to check out the phped manual and read the section about debugging. There is plenty of information in there. It's not a technical problem as your debugging works, so you should manage to get it working with what is written in there. Just got to Help > PhpED Manual and read the "Debugging and Profiling" chapter
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 19 Nov 2007
Posts: 7
Reply with quote
Blizz wrote:
If you set a breakpoint on a non executable line (like on a function definition) it will be moved to the first line that can be executed. So make sure that you set it on an actual piece of code, not on a class or function statement.

You might want to check out the phped manual and read the section about debugging. There is plenty of information in there. It's not a technical problem as your debugging works, so you should manage to get it working with what is written in there. Just got to Help > PhpED Manual and read the "Debugging and Profiling" chapter


Take a look at the screen shot. BTW, I've noticed that the debug session end after I hit F9 the 2nd time Sad


View user's profileFind all posts by DsyfaSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
That is a login function as you said, but wouldn't that be called only if you actually log in? I don't know what you are debugging, but usually the first time you display a site you aren't logged in. You then enter your user details, press submit and then the login process starts (eventually calling the function you show here I assume). Is it possible that it's that what is going on here? If so, it's pretty normal the debugger doens't break, as the piece of code isn't executed.
Normally the debug session etc is maintained between pageviews, so submitting the form should continue the session and land you at that line.
View user's profileFind all posts by BlizzSend private messageVisit poster's website
[resolved] Undefined class controller
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic