debugging a Yii web application using Zend Debugger in Eclipse - php

I have Zend debugger running successfully in Eclipse but I don't understand how to debug a Yii project. I.e, I can debug a single page PHP script but I don't know what the configuration options are supposed to be for a Yii web application.
For example, I was thinking the Controller file would be the file I would select to actuall debug but it says the file can't be found. I've attached a screen shot of what the options are.
I've used the Firefox Zend Debugger extension and that works great. Now, I just want to know how to do the equivalent of that in Eclipse.
The basic options are: File and URL

Have you debugged other applications using Eclipse? If so, it shouldn't be much different:
I'm usually debugging on /, meaning I login to the application, go wherever I need to, then prepare the debugged scenario (including breakpoints where appropriate). Next, I run a "general" debug session -> a new tab is opened on the browser. I ignore this tab and instead go back to the tab where I prepared the scenario I want to debug and continue there.
I usually go with marking / or /index.php as the "debug entry point" (or whatever the term is). If needed (I don't think I needed to with Yii), I would have config some "paths" that tell the IDE that "/" is translated/represented by HTDOCS. Again, I don't think I needed to with Yii (but I debugged little with Yii thus far).
I once had a blog post on debugging Drupal with PDT (which is Eclipse) and xDebug (which is an alternative to the Zend Debugger and essentially the same). You might find it useful: link.
Good luck!

When in a framework, work within the framework rules. If something's not working, don't try to review the code step-by-step. That's unproductive, because you will pass through dozens of encapsulated functions with no discernible order. Yii is built on a singleton pattern, which in my experience makes it just about impossible to know where you are or where you're going.

Related

How to debug PHP MVC site in NetBeans

I need to debug MVC site (PrestaShop eshop solution) to find methods called on specific actions and tweak them. I tried to read the code, but I think that debugging is the only option.
I'm using Netbeans along with Apache. I've got set up a PHP project and enabled xdebug.
When I debug the project it starts at index.php. Pressing f5 will finish the debuggin no matter where I place the breakpoint. Pressing F7 seems to display everything that's being touched.
My question is: how do I debug the way I want? Meaning placing a breakpoint somewhere and waiting for it to be touched?
If you're looking for a specific method and you know the method name, in NetBeans, do a single left click on your project folder, then ctrl-F to open the "find" thingy. Type in your missing method and NB will tell you which file it's in so you can alter it.

Zend OpenID with PHP

I'm using the Zend OpenID library found here. I see there is a demo up, which works beautifully, but I don't see any source included for login.php. When I bring the files into my local apache and try to replicate what I see by viewing the source in the demo, I see an interface. When trying to use one of the login options, I see it makes posts like
http://localhost/zfopenid/public/user/login?action=verify&openid_username=&openid_identifier=http%3A%2F%2Fopenid.aol.com%2F
so there is certainly some php involved in that login file that I'm not able to see. I tried including application/controllers/UserController.php, but I get
Fatal error: Class 'Zend_Controller_Action' not found in /var/www/zfopenid/application/controllers/UserController.php on line 3
I don't know this Zend OpenID library but it sounds interesting. The problem is, at first look, it is tightly integrated into the Zend Framework and not a stand alone library. You'll have to run it as ZF application or find the components and then try if you can use them.
UPDATE If you want to test the downloaded application you have to make the /public directory your web root directory and the index.php your default root file. Then you can open the demo yourself. Again if you like to integrate it into your project it will be difficult because for what I see so far there is code all over the place which makes it increasingly difficult if you want it as a stand alone application.

CodeIgniter with Eclipse PDT, is clean integration possible?

I am attempting to setup codeigniter with eclipse but am getting project errors. From what I understand this should be as simple as creating a new project in eclipse and pointing to the root directory of codeigniter. This properly loads up the codeigniter files but eclipse reports several errors. Looking into the files, it seems like the errors are coming from html files and/or files that print html. For instance, footer.php is showing up as having an error because there is a closing tag but no opening tag. Any suggestions on how to overcome this? At this point would code completion / debugging be too much to ask for as well?
UPDATE: so from what I am gathering from the response below (and searching around on the web) is that when using codeigniter with eclipse one can only take advantage of the code completion / editing features? I also noticed that I am getting NoClassDefFoundError when attempting to open some of the .php files in the eclipse project tree for editing. Surely I must be missing something and there is a way to achieve tighter integration with codeigniter and eclipse? (i would strongly prefer to stick with eclipse as opposed to switching ides) Or maybe this is an issue with my eclipse/pdt setup?
UPDATE 2: I just downloaded the latest eclipse version (galileo) and it seemed to fix all of these issues! except for debugging of course ...
you can achieve tighter integration by initializing the Ci core classes in CI_Base constructor which will also allow you to get auto complete for core classes check out these links:
http://www.gostomski.co.uk/codeigniter/getting-full-auto-complete-with-codeigniter-in-eclipse
http://hetal.wordpress.com/2009/09/04/working-with-eclipse-and-code-igniter/
you will get lots of html errors because the html has been broken into chunks
and is not a complete document
just ignore them thats what i do (there are settings somewhere that control what errors are validated against in eclipse)
i still use the php/html/js code completion and it works fine even with the errors
if you are using svn version control, add subclipse plugin, so you can do that from within eclipse too
Try Aptana.
The last time I checked I was able to do a step by step debug on it and did not see any errors in my project. It is also built on eclipse, so there is nothing new to learn.
For what it's worth, I have been able to get debugging to work using XDebug and the Netbeans IDE. If you cannot get debugging to work in Eclipse you might give Netbeans a try - if for no other reason, to have the ability to debug should you ever need to step through your application's code...

Debug PHP and Control Flow?

I am an autodidact so dont know much about conventional web development however, I have wrote a complete social networking website yet I dont know how to debug. My website has some problems and I need to learn debuggin things around/
First of all I need instructions how to install Xdebug on WAMP (since I use phpDesigner). I tried a lot using tutorials on the web everytime I get a new error. I also tried puting it in the /ext/ directory and activating it from the WAMP PHP Extensions menu. Doesnt Work!
So if anyone odf you out there uses PHPDesigner with Xdebug (not the package that comes along, rather install it on WAMP) please help me and I would really be grateful. BTW PHP version is 5.3.0
Next thing is this is how is the the control flow of my website :-
htaccess -> redirect everything to index.php if file doesn't exist.
index.php ->
include all libraries (__autoload).
initialize classes.
Get the $_SERVER['REQUEST_URI'] to get the $page.
If $page is found
Check if the user is logged in,
if yes then include view/$page.php
or else redirect to login.php page
If page is not found then
redirect to 404.php
Is this control flow good for debugging? because I really cant understand the real MVC concept so I created something like this.
There is a tutorial for installing XDebug for use with phpDesigner here.
MVC is an organizing principle (also called a "design pattern"). It can be helpful keeping logically similar parts of a project together, and encouraging clean interfaces between them, but—especially for low complexity projects—strict MVC modeling isn't always an improvement.
You ask:
Is this control flow good for debugging?
Debugging is to identify flaws in programs. Writing a program to be easy to debug is like intentionally driving a car off the left side of the road so you'll know where to direct an ambulance to find you. Granted—there are small things which can be done to greatly improve debugability. But the point is to architect any control structure so it naturally expresses the algorithm. By doing that, it is far more likely to avoid the need to debug. Anything you can do to write correctly functioning code is justifiable.
Your control flow is clear to me. I wouldn't have any qualms about working on it.
Use xDebug.
Its very easy to install and use.
and you can download xDebug from here http://www.xdebug.org/
step by step tutorial for setup xdebug with WAMP is available at sachithsays.blogspot.com/

Zend PHP debugger: How can I start debugging a page using a get argument?

I am trying out the debugger built into Zend studio. It seems great! One thing though, when I start a page using the debugger does anyone know how I can set a request get argument within the page?
For example, I don't want to debug runtests.php
I want to debug runtests.php?test=10
I assume its a simple configuration and I just can't find it.
I recommend getting the Zend Studio Toolbar. The extension allows you to control which pages are debugged from within the browser instead of from Zend Studio. The options for debugging let you debug the next page, the next form post or all pages. When you debug like this it runs the PHP just like it will from your server instead of from within Zend Studio. It's an essential tool when using Zend Studio.
Just start the debugger on another page, and then change the browser url to what you wanted.
It's not ideal but it should work.
I have high hopes for their next release.

Categories