I have been trying to set up debugging using XDebug in Eclipse for the last few hours without success.
I have the following in my etc/php5/apache2/php.ini file
[XDebug]
xdebug.remote_enable=on
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_autostart=off
zend_extension = /usr/lib/php5/20090626+lfs/xdebug.so
The zend_extensions = /usr/lib...... was given to me by the custom installation instructions on the XDebug site. I followed the setup instructions exactly as they are on that page - http://xdebug.org/wizard.php
But from what I have read typing the command php -m should show XDebug twice, once under PHP modules and once under Zend modules. Well it is showing up under neither for me. So it seems that XDebug is not getting loaded at all?
Anyone any ideas on how to fix this problem and get XDebug working?
You've editted /etc/php5/apache2/php.ini file which is for apache. You'd want to edit /etc/php5/cli/php.ini for the command line interface's options.
If you pass in the phpinfo() from a web site, that PHP has run through Apache of course. And then the wizard will give you settings for the Apache set-up. If you would have passed the phpinfo() output (php -i) from the command line, it would have given you the settings for the CLI.
Something similar happened to me, the first time I setup xdebug in Eclipse it worked just fine, but the next time I tried it, it wasn't stopping at breakpoints. After a lot of research it turned out that I had 2 Eclipse instances running (one for Java and another for Php) and that caused some kind of issues with the debugger.
After closing both instances and starting Eclipse with php workspace first and then Eclipse with java workspace, xdebug worked fine again. My only idea is that debug port was already used when I tried to use it; or something like that.
An other common problem is that you use a router to get through INTERNET and that you had to forward XDEBUG PORT (generaly 9000) on your PC to make XDEBUG working with ECLIPSE.
But your router gives a dynamic IP to your PC and one day your mobile phone connects to the router before your PC and gets the IP address you configuredon you router IP FORWARDING !
The solution getting a static IP from your router. Here is an explanation: http://webologix.com/fr/blog/xdebug-eclipse-fonctionnement-aleatoire.html
Related
How do I get NetBeans to show visual code execution for URL with GET parameters?
In NetBeans I am using Xdebug with a remote server. That is working fine.
The problem is Xdebug with NetBeans only works when debugging files that don't contain GET parameters.
Basically if my file is called index.php, and I go to website.com/index.php?XDEBUG_SESSION_START=netbeans-debug It works.
If I go to website.com/index.php?test=1&XDEBUG_SESSION_START=netbeans-debug or website.com/index.php?XDEBUG_SESSION_START=netbeans-debug&test=1 it runs Xdebug, but I can't step through the code visually with NetBeans.
It seems NetBeans doesn't realize that index.php with GET parameters and no GET parameters is a the same file, and thus doesn't show me visually as I step through the code with the debug buttons.
How do I fix this?
Using:
Apache NetBeans 12.6
PHP 7.2
Xdebug 2.8.0
Windows 10
PHP.INI settings for Xdebug (I am using SSH tunnel hence why my IP is 127.0.0.1):
zend_extension=xdebug.so
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_mode=req
xdebug.idekey=netbeans-debug
xdebug.mode=develop,coverage,debug,gcstats,profile,trace
xdebug.remote_log="xdebug_remote_log.txt"
Thanks!
P.S: I can't use VSCode, or PHPStorm as I am using Namecheap shared hosting, so both those tools don't work.
Apache Netbeans 12.6, PHP 7.2, Xdebug 2.8.0, Windows 10
You need to upgrade, Xdebug 2 and PHP 7.2, are no longer supported.
Your settings also don't make sense, as you mix Xdebug 3 settings (xdebug.mode) with Xdebug 2 settings (the others).
To get back to your question: using GET/POST parameters to start a debugging session is pretty much deprecated. Instead, you can use a browser extension to trigger debugging requests, while your IDE listens for incoming debugging requests. Unfortunately, this is not something that Netbeans supports. Please don't use Netbeans for debugging, as it is so far behind other IDEs such as VS Code and PhpStorm.
I have xdebug (2.6.0) installed on my machine (GNU/Linux Ubuntu 16.04) to debug PHP 7 project running with XAMPP apache 7.2.3, developing on Netbeans 8.2.
Everything is working fine. I opened another project (using the same configurations), added a breakpoint and started debugging the project to fix a bug. As soon the debugger reaches the breakpoint, I can see from glances (a system monitor tool) the memory usage is increasing insanely until it almost reaches 100% and then starts using swap space. That's when the system gets really really slow and I couldn't use it any more. I have to restart the machine to get it back working.
This is a very strange behavior to me and I cannot even guess what to look at or the key words to research with.
I did the usual trials:
Restarting netbeans, XAMPP, and the machine.
Changing the breakpoint
Switching to the previous project and validating that this happens only with the other project in particular.
I googled with keywords like: netbeans - memory blow - system crash - xdebug - breakpoint - PHP - high memory usage
You might find the following snippet off php.ini interesting:
zend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
I solved the problem by clearing/deleting all files and directories at ~/.netbeans (I'm using Netbeans on Linux Ubuntu).
Removing the cache didn't solve the problem. Deleting netbeans project files didn't solve the problem.
I have been programming PHP for quite some time but have never used an IDE or debugger to assist with this process. I decided to try and learn Netbeans with XDebug for PHP code assistance. Setting things up in the ini files was easy enough and I can verify that it is working. However, when I start the debugger in Netbeans it loads the index page of my site and the page I actually want to debug is 5 pages deep and can take a long time to navigate to with the debugger on.
I have installed the Xdebug helper for Chrome but the debugger gets suspended in Netbeans and never debugs anything on the page. Here are the steps I tried with the Xdebug helper. Note: I already set breakpoints in Netbeans.
Navigate to the page I want to debug.
Turn on Debug in Xdebug helper.
Reload page.
Here is the screenshot showing that the debugger appeared to start but suspended and stopped functioning I think.
So, I am looking for a bit of guidance and support figuring out if I may be using the tool wrong or if there is a better way to use it. Is there a way to activate it for a specific page and keep it running to debug ajax requests to php on the same page/project?
System Info
Windows 10
Wamp with PHP 5.6
Chrome, newest version
Using Moodle as a base and customing it.
Netbeans 8.1
Edit
Here is my php.ini information.
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_autostart=0
xdebug.remote_connect_back=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_name=cachegrind.out.%s.%t
xdebug.profiler_output_dir="C:/WampDeveloper/Temp/xdebug"
xdebug.trace_output_dir="C:/WampDeveloper/Temp/xdebug"
I have trying to get this done for days...and reading through about 20 tutorials, documents, etc...but still no luck.
Here is the thing. I installed wordpress(just for example, can be any php program) on my VPS, and hoping to debug it from my macbook and my desktop. This is clearly a remote debugging thing. So I here is what I done:
1.Installed right version of xdebug and located its .so file on VPS.
2.Changing php.ini and 20-xdebug.ini file on VPS, my settings currently are:
zend_extension=/usr/lib/php5/20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port=9200
xdebug.show_local_vars=0
xdebug.var_display_max_data=10000
xdebug.var_display_max_depth=20
xdebug.show_exception_trace=0
xdebug.remote_log=/var/log/xdebug.log
;xdebug.remote_host=202.84.93.66
The last line, which is comment out is my desktop IP address, where I run phpStorm. Based on xdebug's documents, if you set remote_connect_back=1, you won't need this host ip to be specifici.
On phpStorm Side, I "start new project from existing code, and specificy the source root on VPS, map it with one of my local dest. PhpStorm just downloaded all the files and after setting up "Automatic upload", the sync is perfect.
On phpStorm side, I specificy the PHP intercepter as the remote one on my VPS.
On phpStorm side, I changed my debugging port to 9200, as same as the one I using on VPS.
Using the booklet method phpStorm provide, I put them on my firefox bootkmarklet.
Click listen button on phpStorm, set breakpoint, go to firefox open the page, click 'start debuging', refresh.....BUT NOTHING HAPPENS!
I also tried to using the tranditional methods, which set a run configration way as both php-webapplication or php-remote-debug...but still not working.
At php storm, the web debug validation, I could pass all the testing there though....
Can anyone help me with this? I think I must be doing wrong on some very fundation part since I saw all the tutorial are so simple set, but this already took me about 3 days to figure out....
Thanks!
I was able to successfully install both Zend as well as Xdebugger. Verified by Phpinfo as well as Eclipse verifies the Zend debug successfully installed. Although whenever I run debug from eclipse for
Xdebug it hangs at 57%`
and for Zend debugger
the browser keeps processing/busy but nothing happens
Unsure what is causing this
-> Firewall issues?
-> No Selinux in Mac so not sure if it is a permissions issue
Any clues would be helpful.
Thank you.
it seems like a miss configuration of debug. I will try to help you showing my working configurations.
This is my php.ini piece for xdebug.
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_enable=On
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9060
xdebug.remote_handler="dbgp"
xdebug.remote_autostart=On
It is important to note about the parameter debug.remote_host. If your client side is not allowed here, you will stuck on 57%. The value here is the IP of the machine where you are running eclipse. If you are running apache/php and eclipse in the same machine the localhost IP should work.
Adapt zend_extension parameter to your world.
Other reason you can stop in 57% is the web site is not running. Apache/PHP only will send xdebug metadata if the site is running. If you got an internal error, for example, you will be stuck on 57% also. Eclipse stops on 57% waiting for a xdebug session. You must be sure apache/php started a debug session.
Make sure the Debug configuration on eclipse is using the correct PHP server. If you are trying to run eclipse in an invalid PHP server or a PHP server which is not well configured you will stop on 57% also. So review the PHP server parameters on Debug Configurations.
Other important review you have to made is about the Xdebug configuration for eclipse. The port Debug port field must be filled with the same value of parameter xdebug.remote_port. If they are different you will be stuck in 57% also.
Please, let me know if it was helpful.
For Xdebug, this is likely a misconfigured path mapping in Eclipse. There are 10s of questions related to that here on stackoverflow and 100s of hits on google. Please check there first.