PHP XDebug disable breaking on each request - php

I'm writing a webapplication that uses JS and PHP. Each time I refresh I get about 5 ajax calls to my php script. This is getting quite annoying using XDebug since it breaks on each of those request (without a breakpoint placed).
I thought this was a common problem but I can't seem to find anyting about it. Does anyone know how to disable breaking on each request?
EDIT: I'm using Wamp and Netbeans 7.0
Rob

It's the IDE the one that's stopping. In NetBeans, go to Tool-> Options-> PHP-> Debugging and uncheck Stop at first line.
(In earlier NetBeans versions the option was under Tool-> Options-> PHP-> General)

From what i remember, xdebug adds something like XDEBUG_SESS_ID=xxxxxxxx to the url when debugging. if this is the case, then remove that from the url.

What is most likely that you have some empty src="" tags or alike. You need to find out what (by checking your apache logs) which requests are made. Xdebug itself does not decide to make requests.

Related

Is there a back button in the Eclipse PHP Xdebug debugging pointer?

I'm debugging PHP with Xdebug using Eclipse. All went OK except when I would like the debugging pointer to go back to the previous lines. Is this possible? I don't want to restart the debugging.
In details, supposing I'm on line 500 then I proceed to line 505, can the debugging pointer in Eclipse goes back to line 500 to check the state of my variables?
I'm still new to debugging with Eclipse so I appreciate any tips on how this will be done. Thank you.
No, it isn't possible. Xdebug doesn't allow you to do it.
You will have to run the program again from the start to get back to the same point. (unless it's in a loop of course)
This kind of feature is highly sophisticated and requires the debugger to store the application state at all times (starting from a breakpoint) in order to "go back in time" and re-run code.
I haven't seen this with xdebug or even PHP at all. Last time I worked with this feature was in the old C++ days with Visual Studio Debugger. Microsoft invented something they called "IntelliTrace" for this.
(see article about IntelliTrace here: http://msdn.microsoft.com/en-us/magazine/ee336126.aspx)

Using aptana to debug with easyphp +cakephp

I'm starting a new project, for this project, I need a great IDE, which allows me to debug. I thought to aptana after some search.
But this project is a little specific, it has to work with a specific version of php and has not common extension(e.g. php_ingres), so I think I cannot use the internal server of aptana, otherwise it will not find every ingres function.
I've an EasyPhp environnement installed and working.
I've created a new "Simple server" and a new web browser configuration using this webserver(and chrome). But now when I try to debug it, I cannot see my browser configuration, it looks like it display only internal servers here. So is this possible to use aptana with easyphp? If yes, how?
If not, which IDE provide some auto-completion, debugging and allows me to use my own server?
Thank you very much
I think Netbeans can do your job, check this guide :
http://wiki.netbeans.org/HowToConfigureXDebug
Netbeans is great and is free too. But it maybe hard to figure your way around in that for a 1st time user. If money ain't a problem i'd suggest using phpDesigner 7 - http://www.mpsoftware.dk/phpdesigner.php. Easy and simple, with word completion, debugging features and also allows you to setup up an FTP connection to your servers so you can edit your files on the fly.(This method of editing files on the fly however may not be ideal if its mission critical data. I'd suggest using version control platforms like git, read more here - http://progit.org/book/ch1-1.html )
I finally used code lobster, which is not the best editor but can use easyPhp and actually debug into it.

zend debug multiple pages

I have a pretty simple setup:
Apache server, PHP 5.3, Eclipse, PHP Zend Debug Module
When I click on debug it sees my breakpoints and everything works fine. But only for the first page. If I click on a different page within the integrated browser, all breakpoints from that moment forward are ignored. I think it has to do with the fact that the first page's URL is something similar to
http://localhost/schedule?start_debug=1&debug_host=127.0.0.1&send_sess_end=1&debug_session_id=1003&original_url=http%3A%2F%2Flocalhost%2Fschedule&debug_start_session=1&debug_no_cache=1303403971996&debug_port=10000
Whereas pages after do not have these URL debug parameters appended. Is this a limitation with debugging in eclipse, or is there some way to append these GET parameters to every link I click? Perhaps a browser extension?
Looking under advanced for my debug configuration, I see that I have "Debug All Pages" checked.
I recently tried the Xdebug extension for the same thing, and i can really recommend it.
Xdebug does exactly this, and also sets a Cookie which contains the debug session info, so you can browse through the Website and the debugger will halt on a breakpoint. So it's definately not an eclipse issue.
You could check if the Zend Debug Module does the same thing by calling the above URL in Firefox and checking if a cookie was set.
Greetings and Good Luck

How to do Debugging of PHP?

how we do basic debugging in PHP ?
Can anybody share true horror story on debugging PHP application (or (even better) on PHP framework such Codeigniter and Wordpress) ?
i love to hear real experience in case i have to encounter similar situation on my journey to learn PHP.
XDebug may be used to debug a PHP application. Basically you install this on your server and configure it in PHP.ini. Then on your desktop machine, you can setup Netbeans (and maybe Eclipse, but I have not tried that) to remote debug. When you are in a remote debug session you can do any of the things you typically expect: set breakpoints, step through code, etc.
One major annoyance when using CodeIgniter with mod_rewrite is that the debugger gets confused by index.php not showing up in the URL. I am not sure if this is a problem on the client side or server, and whether CI "eating" the GET portion of a URL has anything to do with it. In any case, I have worked through it by copying a 'debug.php' file to the server and starting debugging with that file - everything seems to work fine after that.
I any case, I highly recommend you get setup with XDebug at some point. You may not use it everyday, but when you need it you'll be thankful you did your homework ahead of time.
Easiest option (without installing any IDE) is to use firefox FirePHP addon.
Download and install FirePHP firefox addon
Download FirePHP core library from their website
Extract FirePHP library you downloaded in step 2 and only copy FirePHP.class.php to CodeIgniter /application/libraries/ folder, but give it a name FirePHP.php without the class part
Turn PHP’s output buffering on
Start your Firefox, click the FireBug icon on the bottom lower area, or go to menu and select tools. After you turn on (set them to enable) FireBug and FirePHP, be sure to click on the Net tab next in line to HTML, CSS, Script, DOM and set it also to enable.
See this link for how to use firephp library: http://speedtech.it/2009/05/debugging-a-codeigniter-application-with-firephp/
There is one problem in using IDE debugers - it's bad for debuging AJAX applications. In this case you will need to use some of browser extension. For FireFox it's FirePHP, and gor Google Chrome it's Php console.
I checked out a lot of debuggers 2 years ago when I wanted to set up a debugging environment for myself in PHP. I posted a brief post on this, you can go through it http://forums.codewalkers.com/general-chat-93/which-php-ide-to-use-840352.html
Bottomline was that Nusphere's phped was the best and its debugbreak() function makes debugging a real bliss. With codeigniter also this works fine, no tweaks required if you have already enabled get variable. The only hiccup with codeigniter+phed is that, you cannot do code navigation like "right click and find declaration" for other files models.
Off late I have been checking out codelobster they have a codeigniter plugin, but I am not through with it yet.

REMOTELY Debugging PHP Using Eclipse

I'm a self-taught noobie, trying to debug PHP on my GoDaddy hosted server. Is this idea even rational, or do I need to continue to do all development locally and just continuously re-ftp upload the changes?
Is there some way that I can use eclipse to step through, and debug my php scripts that are hosted on a third party site?
Although I have only used Netbeans and XDebug for remote debugging, it should be possible to use Eclipse PDT and XDebug. See:
setting-eclipse-pdt-and-xdebug
Debugging PHP applications with xdebug
One caveat, however. To configure xdebug you will need to modify some settings in php.ini - I am not sure if this will be possible on a hosted server. If not, you would need to have a local server that you use for debugging, and would need to figure out another solution for your "production" environment. Which may not be a bad idea, actually, as it would give you a good place to test your changes without risking breaking anything on your actual site.
Also, I recommend that you look into Netbeans, if for no other reason than to experiment and see what it can do compared to Eclipse. One nice feature is that you can set it up to automatically ftp (or scp) changed files to the remote site. So you can make some code changes, click the debug button, and after waiting a moment for your files to upload you can be stepping through code on the remote site.
While there is definitely a case for remote debugging you should always be working locally and then uploading. Anything except the most minor of changes should be done locally tested then pushed to a server - sometimes production directly, sometimes a testing server...
Yes Eclipse supports remote debugging with Xdebug as well as the one from Zend Debugger check out Justin's links as well as This one for Zend Debugger. I think Zend has an all in one with pdt+deps and Zend Debugger - ofcourse you still need to set up the extension on the server (note link is for setup on windows but hte process should be similar).
Obligatory "Ewww GoDaddy" :-)
If the web server have XDebug installed, then you can do debugging with it. Searching for it in google yield a quite num of articles on how to do it.
Personally, I'm using CodeIgniter. I do debugging using FirePHP and PQP. Make a habit to write a good indented code. You might find your code have less bug, both syntax and logic, and easier to maintained in the future. Use a consistent white space, either tab or space. Use a consistent bracket style. It will save you from the headache when re-read it for bug or adding more feature later.
I have never needed to do a step by step debug in PHP, but when I do need to debug I just output strings of the variables at that point.
However, one thing that I found, but again never used, was FirePHP:
http://www.firephp.org/
As far as I'm aware, this is not possible in Eclipse, it is, however, possible in NetBeans, but as Nathan stated, I've never really needed to remote debug any of my PHP scripts.

Categories