Debugging PHP files on browser with Eclipse and xDebug - eclipse

I have been reading online about debugging with PHP for Developers on Eclipse and xDebug.
I have installed all the necessary files for xDebug, and now when I am in Eclipse I can run the debugger with a script and it works just fine.
The issue is that i am using AppServ (Apache, PHP and MySQL) on my Windows machine, and what I would like to do is to debug my PHP files in Eclipse when I am loading the PHP pages in my browser (instead of running them as scripts in Eclipse).
Is that possible?
Joel

In Eclipse, go to 'Preferences' then 'PHP' 'Debug' 'Installed Debuggers', 'XDebug', then 'Configure'
For 'Accept remote session' change this to 'localhost'
This will tell XDebug in Eclipse to debug whenever anyone connects with xdebug cookies or URL params set - using this with Easy Xdebug or xDebug Helper then makes debugging from realistic in-browser contexts a doddle.
I'm assuming you have Eclipse PDT for this, I'm not sure if the steps are different otherwise.

I'm not sure if this is what you ask for, but you can take a look and decide.
Easy Xdebug with Firefox https://addons.mozilla.org/en-US/firefox/addon/easy-xdebug/

Here at Oodles Technologies, we work with PHP on an extensive basis and hope this answer helps.
After opening your the php.ini file, add the following lines:
Note : (php.ini file contains in both the folders that is apache and php, it is advisable to configure the file which is present in apache folder)
<span style="font-size:16px;"><span style="font-family:arial,helvetica,sans-serif;">zend_extension = "c:/wamp/bin/php/php5.4.3/zend_ext/php_xdebug-2.2.0-5.4-vc9.dll"(use zend_extension_ts as variable name if you are using php version below 5.3)
xdebug.remote_enable = 1
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
</span></span>
After this, Make sure that "c:/wamp/tmp" exist in file system, if not then create that directory.
Then Restart your apache services.
Lastly, open your NetBeans or eclipse IDE and configure xdebug in settings.
I hope you find it useful.

Related

NetBeans 12.2 not connecting to Xdebug version 3

Got a problem I need to get working. I'm having difficulty getting NetBeans 12.2 to connect to Xdebug. When I try to debug I get the dreaded "Waiting For Connection (netbeans-xdebug)" which never connects. I'm running the following:
PHP version 8.0.2
Apache 2.4.46
Xdebug 3.0.3
I've read some of the other threads e.g.
netbeans shows "Waiting For Connection (netbeans-xdebug)"
Netbeans waiting for connection to XDEBUG
but they are for older versions of Xdebug and the solutions don't seem to work/commands are not the same. Having read the documentation and reading a solution in another threat my php.ini file has this at the end:
[xdebug]
zend_extension = C:\xampp\php\ext\php_xdebug-3.0.3-8.0-vs16-x86_64.dll
xdebug.client_port = 9003
xdebug.remote_handler = "dbgp"
xdebug.client_host = "localhost"
xdebug.mode=debug
xdebug.start_with_request=yes
When I click debug and run netstat I can see port 9003 is listening, but for some reason this just won't connect. I need this for work so I'm hoping someone can help a noob out? Best regards.
I had the same problem, and these are the steps how i solved it:
I reinstalled XAMPP, because I ruined my php.ini file due to configurate it too many times.
Then I followed the steps from the Xdebug homepage. You can overread it fast if you don't focus.
2.1 Download the .dll File and place it in your "Xampp/php extension directory" (C:\xampp\php\ext)
2.2 Name it to: "php_xdebug.dll"
2.3 Open the php.ini File (C:\xampp\php\php.ini)
2.4 Implement following line: "zend_extension = xdebug"
Note: I don't know if the order is important but for just in case put this Line under the following line: ";extension=shmop"
2.5 Activate the step debugger with implementing following lines:
"xdebug.mode=debug" (tells that
"xdebug.start_with_request=default"
Note: Here the same, put these lines under the following line: "extension=php_ftp.dll" (You can search for it, with the right editor)
Now you are finished with the php.ini file and can start with the Netbeans configuration.
The debug configuration in Netbeans (Tools > Options > PHP > Debugging):
Netbeans configuration
The project properties in Netbeans (right-click on project > properties):
Sources
For Source and Project Folder I entered the same directory, in this case my Project.
(right-click on project > properties > Run Configuration):
Run Configuration
Links:
https://xdebug.org/docs/step_debug
https://xdebug.org/wizard
My PHP xdebug config:
myphpinfo() - xdebug_config
Note: Step Debugger has to be enabled
PS: I tested this config. with PHP-8 and xdebug-3 and as "localhost" on Windows 10. It doesn't work for older versions!
I hope it solves your problem, i would be happy about a feedback!
There can be many reasons:
1.Missing php ini config
xdebug.idekey=netbeans-xdebug (or the value from netbeans settings - Session Id)
~ I think that form a specific version of netbeans 12.* this has been removed, but still you can give it a try
try to configure the path mapping
Map the xamp simulated server path to the real path on your computer
To see your server path you could try to do a var_dump($_SERVER['DOCUMENT_ROOT').
It must be written as in linux format using '/' sepparator.
3.Optional If you are debugging with chrome check if the netbeans connector addon is enabled. Try to debug also with other browsers like firefox or edge to see if there is a difference.

Eclipse PDT + XDEBUG - source lookup not working entirely

I'm having trouble with a PHP project using Yii framework.
My setup is the following: Win7 + Eclipse4.2 + PDT 3.1 + Yiiclipse PDT extension + WAMP Server with XDEBUG enabled.
Pretty much everything works ok. The debug session starts, it's going through project's index.php source, but when it has to jump to framework's files, it doesn't open them up. I edited source lookup and added framework's local path but it simply cannot find them.
Here is a screenshot: http://img607.imageshack.us/img607/3687/eclipsepdt.png
This isn't necessarily an answer - but your question isn't necessarily a question either, so I feel like this is fair game :D
I've had so many problems with Eclipse PDT + xdebug in the past with debugging, code completion, etc., that I gave up on it a while ago and switched to Netbeans for PHP Debugging. It's now the defacto standard on my development team for debugging PHP; even though we all still have our own favorite editors, when we need to debug we'll still use Netbeans.
Code completion, phpdoc 'tooltips' on completion, and debugging all work flawlessly for me regardless of what platform I'm developing on (Windows, OS X, Linux) and I cannot say the same about Eclipse PDT (code completion would often miss, I'd run into problems or crashes debugging,etc.) in my personal experience.
So, I apologize in advance if this is a non-answer to a non-question - but maybe try out Netbeans?
Are you sure, you can use Xdebug to debug Yii (or any other framework-based) applications at all? Since Yii introduces URL-rewriting based on MVC pattern, I think you can't.
I don't have much experience with Xdebug, but from what I have found I clearly see, that it (along with Eclipse PDT) strongly depends on URL shown in Eclipse's internal browser, when debugging.
So, taking for example an URL from your screenshot:
http://localhost/testdrive/index.php?r=dispozitive
As you mentioned, Eclipse has correctly opened index.php, which is normal, as it is directly referenced in URL and you problably pointed it out as start file in debug configuration window.
Buth going further. How would you like Eclipse to understand, that route dispozitive (where route itself is a completely Yii concept (or similar framework) and Eclipse / Xdebug / PHP knows nothing about it) or that ?r=dispozitive URL parts corresponds to executing protected/SiteController.php file in your file system and calling default actionIndex() from it? So it could know it should open it in IDE and possibly stop execution on there defined breakpoints.
This process and concept (routing) is 100% authored by Yii and done by it internally, so how would you like Eclipse or Xdebug to know anything about it?
As I wrote, I don't have much experience in debugging Yii applications, but from what I have found until know, I clearly see, that you can't debug PHP applications with Xdebug, if they are using any kind of URL-rewriting methods. This technique (debugging with Xdebug) works IMHO only in case of applications, where URL changes directly reflects files in filesystem in your application contents.
EDIT: Additionally, check which version (package) of Eclipse you have? It turns out, that Helios package has some bugs and doesn't stops on breakpoints. Which makes it pretty useless for debugging process. You should consider using Galileo Package Eclipse for PHP Developers instead.

Setup eclipse PDT to debug website residing on remote server with Xdebug

I have tried a lot but not been able to understand the steps involved in debugging a PHP website residing on a remote server with eclipse Indigo PDT and Xdebug. Following is my configuration.
Remote:
LAMP, Xdebug(fully setup)
Local:
LAMP, Eclipse PDT with RSE,
My main problem is about the setup that I need to do locally with eclipse to be able to debug the remote website.
Specifically:
Do I need to create a new eclipse project locally? If yes, where should I load the source files from and how? Do I need an exact copy of the source files as on the server?
Do I need to have all the files locally before I can start debugging? I copied only index.php to a local project and started debugging. I received the remote connection when I started debugging the website and could step through index.php, but not after that. If I don't need to have all the source files locally beforehand, how can I set a break point in a file that is reached after 20 function calls?
What other settings need to be setup to link the local and remote projects. Do I need to add a new PHP server? What should be the settings of the debug configuration?
I know about sshfs and tried to set it up using this link:
http://www.docplanet.org/php/how-to-debug-php/
but eclipse took forever to build project files on the server and hung.
I have looked all over. A good link to go with the answers will be appreciated.
Thank you.
I posted the question on eclipse forums too and got an answer:
http://www.eclipse.org/forums/index.php/mv/msg/365474/890896/#msg_890896
So here are the answers:
Yes, you need source files and an eclipse project locally. No debugger delivers source files. I read on SO that for PHP we only need the lines that are being debugged to be same, while for C# the whole project has to be a copy.
Yes, you need the files locally and set your break point in them.
One thing I found is that you don't need to start the debugger like we do with normal projects. Eclipse starts accepting the debugging connection the moment you setup the debugger.
So you just need to open the webpage with debugging enabled and eclipse will catch the connection and let you know.

Magento Code Debugging Through Eclipse PDT

I am trying to debug Magento Code through Eclipse PDT. I configured X-Debugger properly and apply breakpoints in index.php file and launch the debugging session. I started debugging the code line by line but it get stop at last line of index.php file.
Actually i just want to debug the one-page checkout process of Magento. I have applied breakpoints in OnepageController.php file and gone through Onepage Checkout process but Eclipse does not stops at break points. Please help me.
I was busy for many days to find an installation (in 2012) for debugging Magento. Eclipse, Netbeans and PhpDeveloper all failed for XDebug (stopped only at first breakpoint) in a Xamp installation (my experience) and I could not load a ZendDebugger.dll as well. You find indeed a lot of outdated articles about this subject.
But finally I can debug Magento without problems (you need a debugger as a professional for Magento). I downloaded Zend Server CE and if you have a latest Eclipse PDT version downloaded (take the one from Zend) debugging works like a charm (all settings are done already by Zend, so no mistakes and wasting of time anymore). You should see when a webpage had finished that the php program had terminated (no error, is normal, for a next page php programs are started again). One problem yet Connect Manager does not install extensions anymore, BUT while debugging admin it works too (yes funny, but that’s Magento, it takes all your time). You can debug admin by adding /admin to the url in the debug browser window (just that simple).
Now the debugger is working fine, i think the problem was occurring due to wrong configuration of eclipse PDT. To know how to configure eclipse PDT and X-debugger
please visit
http://devzone.zend.com/1147/debugging-php-applications-with-xdebug/
http://subesh.com.np/2010/01/debugging-magento-eclipse-pdt-zend-debugger/

Unable to read repository at http://download.eclipse.org/releases/indigo

I was trying to add the PDT,
Indigo - http://download.eclipse.org/releases/indigo
Unable to read repository at http://download.eclipse.org/releases/indigo.
Unable to read repository at http://download.eclipse.org/releases/indigo.
http://download.eclipse.org/releases/indigo is not a valid repository location.
So what's the correct url ? I went and looked lots of places. Can someone point me to the exact link ?
Edit :
Problem once you go to http://download.eclipse.org/releases/indigo , you will see the below error. So I guess its moved somewhere.
This software repository URL, http://download.eclipse.org/releases/indigo/ , provides access to the software repository for the Eclipse indigo release. Until its released in June 2011, it will contain milestone builds.
The repository site URL is typically pre-populated in the list of software repositories when you install the Eclipse Platform or SDK.
For more information about installing or updating software, see the Eclipse Platform Help.
There is also a collection of handy, downloadable all-in-one zip files available for many interests and platforms. Many people find these all-in-one packages the easiest way to get started.
Can you connect to internet at all through Eclipse?
Open the internal webbrowser. In Eclipse: Window -> show view -> Other -> General: Internal web browser.
Look up any normal adress, is it working?
Can you connect to another update site? Try for example Eclipse Emma:
http://update.eclemma.org/
Do you see anything there?
What are your proxy preferences? Go to Window -> preferences -> General: Network connections.
The active provider:
Specifies the settings profile to be used when opening connections. Choosing the Direct provider causes all the connections to be opened without the use of a proxy server. Selecting Manual causes settings defined in Eclipse to be used. On some platforms there is also a Native provider available, selecting this one causes settings that were discovered in the OS to be used.
If internet is working fine outside of Eclipse, try changing to Native. After that, try Direct.
I have encountered problems where an update site would not load, then I had to remove it and add it again. This forces Eclipse to reread the contents of the site even if it has a cached copy. So, if you still get no connection to the indigo update site, but everything else is working, try that. Go to Window -> Preferences -> Install/update: Available Software sites. Then remove and add the indigo site. Just remember to copy the adress so you can add it again.
As suggested in a comment below by #lostiniceland, this is a simpler way to achieve the above:
Goto Window -> Preferences -> Install Update -> Available Software Sites => select the entry and click the "Reload" button to the right. This is sometimes also helpful when you have a local updatesite for testing custom plugins
I had the same problem and resolved it by
Deleting the cache directory \eclipse\p2\org.eclipse.equinox.p2.repository\cache
Refreshing the repositories.
Preferences -> Install Update -> Available Software Sites => select the entry
Click the "Reload"
Check if you are able to connect to eclipse market place url (http://marketplace.eclipse.org/) from browser. If its working then the issue is because of proxy server using in your network.
We have to update eclipse with proxy server details used in our network.
Go to :- Windows-> Preference -> General -> Network Connections.
And edit HTTP ,with proxy details.
Click OK
Done.
I was having this problem and it turned out to be our firewall. It has some very general functions for blocking ActiveX, Java, etc., and the Java functionality was blocking the jar downloads as Eclipse attempted them.
The firewall was returning an html page explaining that the content was blocked, which of course went unseen. Thank goodness for Wireshark :)
Another way to solve this kind of error is to start eclipse with this argument
-vmargs -Djava.net.preferIPv4Stack=true
Working fine with Eclipse (x64) 4.3.1
Had this problem in Linux, and I found that the user doesn't have permission to update the eclipse directory
change the owner of eclipse folder recursively, or run eclipse with user who has write permission to the folder
In Windows 7 32-bit version, I started the eclipse with as an administrator. This worked for me.
I had the same problem. Try to deactivate your Firewall (I had avast!), which worked for me.
(Sorry for my English I'm French :D)
Please make sure you are using correct url. If You are using url - http://download.eclipse.org/releases/indigo on your eclipse luna(v4.4) then it might be not working in this case you should use - http://download.eclipse.org/releases/luna
I have tried this and its working.
What worked for me:
Since yesterday, I have been trying to install the Eclipse plugin - "Remote System Explorer" from the Eclipse marketplace on a freshly downloaded Eclipse 4.8 as shown below,
and everytime I was getting this error:
Unable to read repository at http://download.eclipse.org/releases/kepler/.
Unable to read repository at http://download.eclipse.org/releases/kepler/201306260900/content.jar.
download.eclipse.org:80 failed to respond
which brought me to this SO post.
I tried a few solutions mentioned here in the different answers like this one and this one and this one, but none of them worked. I just gave up almost, thinking that either the corporate network here is somehow blocking the specific download requests or the 4.8 version of Eclipse is buggy.
Discovery:
I could not reload all the paths under 'Window' -> 'Preferences' -> 'Install/Update' -> 'Available Software Sites'.
Preconditions:
What did work for me from the beginning was:
I could open google.com from the internal web browser of eclipse and,
some of the update paths, I could reload even. (As was mentioned as a possible solution or test, in some of the answers here, like this one.)
Finally, this answer put me on the right track - for my specific case, at least. Just my step was to do the exact opposite of what that answer was doing.
Solution:
I had to change all the http:\\ paths to https:\\ and suddenly it started to work. I don't know who - either IE/Edge on Windows 10 or the Windows 10 firewall or the company firewall is blocking HTTP communications. But with HTTPS, I can finally install plugins from the Marketplace.
HTTPS reload works
I must say, what is strange is that not all the paths required https. Except a few, the rest seemed to have had no problem working with HTTP. But I anyways changed all to HTTPS, just for good measure.
Then reload all the repositories one by one. Press "Apply and close".
Then check for updates. Eclipse will update itself successfully now.
Restart after update.
Finally you can install whichever Plugin you would like to from the Eclipse Marketplace.
Note: In case during the update, this same error pops up again, then see in the repositories that any new paths added by eclipse during the update, are also HTTPS and not HTTP.
Kudos to #Fredrik above. His answer didn't work for me, but lead me to the resolution of my issue:
In 'Window'|'Preferences'|'Install/Update'|'Available Software Sites'. The location that I was attempting to install from the 'Marketplace' was getting inserted with an https:// URL. Editing this to http:// allowed me to then use 'Help'|Install New Software ...' to select the repository from the drop down 'Work with:' combobox instead of having the https:// one automatically inserted and used.
For eclipse, there are normally different options available:
If you want to use the PHP development environment (only), you should go with the corresponding distro of eclipse. There is a distro for PHP provided by Zend.
You may add PDT to an indigo release by doing the following steps:
Check if an update site for PDT is included in your eclipse installation:
Open the Help > Install New Software dialog.
Click there on the link Available Software Sites.
In the list, the URL http://download.eclipse.org/releases/indigo should be marked.
Close the dialog.
Select from the Work with list the site with the right URL.
Enter in the filter box PDT and search in the list for the PDT tooling you want to install.
Install the PDT tooling.
If that does not work, you may download a complete update site from the PDT project site.
Visit the site (URL above).
Click on downloads.
Search there for the string "all in one update site".
Download the zip file.
Install it in your Indigo installation. Help > Install New Software > Add... > Enter name and select from button Archive the zip file
I hope some of the installation instructions will work for you.
This is the correct URL. Chances are Eclipse cannot read it properly because of the Internet connexion.
Are you using a proxy to get Internet access? If this is the case you need to notify Eclipse via the "Preferences/General/Network Connections" menu.
That URL works fine. The message you report is normal when you look at it in a browser. My copy of Eclipse has no problems talking to it. If yours does, I suspect a proxy configuration error in your copy of eclipse.
Also try it by turning off the firewall, and similar services. It worked for me!
If you can't access https://dl-ssl.google.com/android/eclipse/ simply
try to use http://
instead of https://
I spent whole my day figuring out this and found the following. And it works great now.
This is basically an issue with your gateway or proxy, If you are under proxy network, Please go to the network settings and set the proxy server settings(server, port , user name and password). If you are under direct gateway network, your firewall may be blocking the http get request from your eclipse.
I was also unable to read the repository. Even after the disabling most of the entries under Available Software Sites things were still not working.
I had no proxy to worry about and even disabling the firewall (which I do not recommended) as a last resort did not help.
Viewing the error log, from the dialog box which Eclipse displayed, there was mention of a cache directory under .eclipse in my home directory. I deleted the two cache directories I found and Eclipse was working again.
For my setup the two directories I deleted were:
.eclipse/org.eclipse.platform_4.4.2_119745494_macosx_cocoa_x86_64/p2/org.eclipse.equinox.p2.core/cache
.eclipse/org.eclipse.platform_4.4.2_119745494_macosx_cocoa_x86_64/p2/org.eclipse.equinox.p2.repository/cache
NB: My setup is Eclipse Luna 4.4.2 running on Mac OS X Yosemite 10.10.3
In my case, I discovered that the major issue why my eclipse won't connect to internet is my Internet Service Provider. I was only able to browse some websites but unable to browse other website. Fixing the issue with the ISP worked.
My issue was the Eclipse Marketplace client needed updating.
After trying Fredriks solution of
Go to Window -> Preferences -> Install/update: Available Software sites. Then remove and add the indigo site. Just remember to copy the adress so you can add it again.
The Marketplace client wouldn't load. But I could access it via a browser.
So, I went to the Help -> Eclipse Marketplace
it loaded fine
Clicked on Installed and found the Eclipse Marketplace Client and it had so i clicked it it updated and then when I did the standard update everything worked.
Sometimes, there will be firewalls and restrictions in the network preventing the plugin to get downloaded. We can try some other network. This actually resolved my issue.
I was facing the issue while adding team explorer plugin to eclipse from https://marketplace.eclipse.org/content/team-explorer-everywhere.
Used team explorer plugin for ecplise for internal use of xamarin for mac.
Error:
unable to read repository at http://marketplace.eclipse.org/content/team-explorer-everywhere
org.eclipse.equinox.p2.core.provisionexception unable to read repository
Unknown host exception
Goto https://github.com/microsoft/team-explorer-everywhere/releases
Download: TFSEclipsePlugin-UpdateSiteArchive-14.135.0.zip
From Eclipse->Help->Install new software.
From Add Repository window select Archive select the downloaded zip file.
Continue installation.
Also try if in the eclipse paths there is some duplicated
Luna - http://download.eclipse.org/releases/luna
Luna - http://download.eclipse.org/releases/luna/1234567...
Try both of them, one may work.
In my case, with 2 eclispes installed, in one of them the path
Luna - http://download.eclipse.org/releases/luna
works, in the other one, i must select:
Luna - http://download.eclipse.org/releases/luna/123456...
In both the internal browser can access to internet. Both are Luna (but one is RCM, the other one i don't remember).
No meu caso era o anti-vírus que estava bloqueando a conexão do eclipse, desativei o anti-víruse tudo funcionou o//.
Translation:
In my case it was the anti-virus that was blocking the connection from eclipse. I disabled the anti-virus and everything worked.