Yii Framework Forum: Debugging Yii Project With Netbean Ide And Xdebug - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Debugging Yii Project With Netbean Ide And Xdebug Rate Topic: -----

#1 User is offline   Trinh Duy Hung 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 73
  • Joined: 26-October 12

Posted 16 November 2012 - 11:48 PM

Hello everybody!
I've just started learning yii framework from 3 weeks ago.
I just did some searches on the topic: debugging Yii projects with Netbeans IDE and XDebug.
I've configured XDebug with my Netbeans IDE and seems like everything works fine except one thing.
For example, I've created a project named "demo" using yiic command line tool. By default Yii created for me SiteController.
In address bar of Google Chrome I type "localhost/demo/index.php?r=site/login". This will open the login view in browser. I wanna see what happens when I do that, so inside my Netbeans IDE I set a break point at the beginning of the function actionLogin() that is inside file SiteController.php. On the Projects view I right click on the demo project and chooses "Debug", inside my Google Chrome nothing appears except at the address bar it says "localhost/demo/index.php?XDEBUG_SESSION_START=netbeans-xdebug" and the browser says it's waiting for localhost. The IDE stars debugging index.php file (the entry script file for project) and from there I can step one by one line. But the thing is I want to see how actionLogin works and how everything changes after for example I've logined successfully. So I start again the process, but now instead of debugging whole project I chooses Debug-> Debug File (Ctr + Shift + F5) and get the error: "Access forbidden!". Inside browser's address bar I see "localhost/demo/protected/controllers/SiteController.php?XDEBUG_SESSION_START=netbeans-xdebug". This error occurred because the existence of file .htaccess inside /demo/protected folder. I remove that for a second and start again the process. Now I get something like "Fatal error: Class 'Controller' not found in C:\xampp\htdocs\demo\protected\controllers\SiteController.php on line 4". The problem is the script didn't find the declaration for class controller. Now I'm really stuck at this step.

Hope you guys can give me a point to get through this issue!

Thanks in advanced!

P/s: what I really want is to see everything like the process of calling functions, variables's values, the values of ActiveRecord instance,... If is there any extension that meets my need. Just let me know.
0

#2 User is offline   CodeButterfly 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 30-August 12

Posted 17 November 2012 - 12:33 AM

Don't try to debug a single file that won't work the way you think. Instead debug the entire project the way you were doing it before.

Two options:

If you truly want to see how everything works set a breakpoint inside your index.php file on this line:

Yii::createWebApplication($config)->run();


Then debug your project in netbeans. Netbeans should stop on the above line. Hit F7 (step into) command to step into functions line by line.

Alternatively,keep your breakpoint in actionLogin. Debug your project and browser opens with this url:

localhost/demo/index.php?XDEBUG_SESSION_START=netbeans-xdebug

If it's automatically stopping in index.php without you setting a breakpoint that's probably your netbeans settings. Go to Tools->Options->PHP->Debugging and uncheck "Stop at First Line". In any case you can just press F5 to allow execution to continue.

Next type your login url into the browser as follows (note you don't need the xdebug query string parameter once you have started debugging):

localhost/demo/index.php?r=site/login

This should trigger your actionLogin breakpoint
0

#3 User is offline   Trinh Duy Hung 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 73
  • Joined: 26-October 12

Posted 19 November 2012 - 01:18 AM

@CodeButterfly
Thank you very much. This is what I've expected.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users