Debugging Yii Project With Netbean Ide And Xdebug

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.

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:


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:


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):


This should trigger your actionLogin breakpoint


Thank you very much. This is what I’ve expected.