PHP debugging - where to set breakpoints? How do I verify the authenticity?

So, I recently took the step from custom debugging with dump

, print_r

and echo

to more complex methods, and I have a struggle.

I am working with Zend Framework, Aptana and Zend Debugger.

At this point, I am trying to debug a custom controller and whatever I am trying, I am not getting to a breakpoint that I understand, since there is authentication and menu use between the two.

Questions

  • How can I make my application crash at the time of authentication, login to the browser, navigate to a specific uri, and then continue debugging?
  • What are good places to set breakpoints in Zend Framework with MVC?
+1


source to share


4 answers


Do you want to change the current user authentication details in the middle of the request?

I do not think that's possible. Zend Debugger is pretty much a reading tool. Even so, you are assuming that whatever infrastructure you use can handle it. This would mean that you have to constantly try to synchronize its internal state with changes in the input data.



I think instead of asking us how to solve this particular problem, you should tell us why you need to change the authentication. It looks like you are running the script in your debugger, which fails because you don't have a user session.

Zend Debugger has a browser toolbar ( http://files.zend.com/help/Zend-Studio-Eclipse-Help/zend_debugger_toolbar.htm ) that allows you to launch the debugger for the current page; The debugger will have all the information the browser has sent: cookies, post data, etc. It even has a "debug next page" option to help debug POST forms. It looks like this is what you want.

+1


source


Wouldn't it be easier to set up a constant like:

define('MODE_DEBUG', 1);

      

Then check the authentication process:

if($obj->myLoginMethod() || constant('MODE_DEBUG') == 1){

}

      



No one will be able to insert this constant, and the worst thing that can happen is to end up leaving debug mode on my error ...

What could you put before the definition:

define('MODE_DEBUG', (false !== strpos($_SERVER['HTTP_HOST'], 'dev.mysite.com') ? 1 : 0));

      

+1


source


Maybe you just need to rethink the dump solution (I like the idea of ​​using breakpoints, but came back after a hiccup like your experienced one and I use Zend Studio). For debugging my applications I am using Zend_Log and a firebug writer for Zend_Log. Firebug prints log to firebug (NB you must have firephp to install firefox). Keep the logger in your registry and you can do a lot of debugging without messing up your looks with ugly dumps.

+1


source


Ok, so I played with the zend debugger again. (your question pissed off the old daemons) and I finally figured out the "correct" way to debug. To answer your initial post-login debugging question, I'd say install the zend panel for Firefox or IE. To the right of the Debug menu item is a drop-down list with some options. One of the options is "next page". So you can go to the login screen, select Next Page and then enter your credentials and submit and the NEXT page is debugged.

0


source







All Articles