Debug PHP with XDebug in Netbeans - php

I'm trying to debug PHP code with Netbeans 8 (with Java 1.8.0) on a MAMP 3.0.3 (PHP 5.5.10) server, the whole thing running on Mac OS X 10.9.2. But when I launch the debug, Netbeans shows a progress bar saying "Waiting For Connection (netbeans-xdebug)". it never stops, so I suppose it never gets a connection. And of course, the execution of my webapp never stops on my breakpoints.
Here the xdebug configuration in my php.ini:
[xdebug]
zend_extension="/Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=on
xdebug.idekey="netbeans-xdebug"
xdebug.remote_log="/Applications/MAMP/logs/xdebug_remote.log"
I tried many things found on forums or even here on stackoverflow, but nothing works. Among them: change the port (in the php.ini and the debug conf in Netbeans), change the localhost to 127.0.0.1 or to my real IP, comment out the remote host, check if my timezone was set in the php.ini (it was), load my waebapp with a parameter XDEBUG_SESSION_START=netbeans-xdebug and much more.
Any idea? I'm open to any suggestion, at this point...

Double check your path mapping.
https://blogs.oracle.com/netbeansphp/entry/path_mapping_in_php_debugger
Then download a trial of PHPStorm and see how that works. If it works fine, consider switching to it. Honestly not trying to be smart, I think its a valid solution to this issue.
http://www.jetbrains.com/phpstorm/
http://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm

I added a webroot and an index file in the Netbeans configuration (copying from a colleague's configuration, which is working properly), and now, it works. I won't pretend I really understand why. It seems really fragile, so I won't mess with it just for the sake of understanding...

Related

netbeans xdebug waiting for connection despite going through all forum answers

I get the message "waiting for connection (netbeans-xdebug)" when using netbeans debugger.
I am using:
Windows 10
XAMPP for Windows 5.6.20
XAMPP control panel v3.2.2
NetBeans IDE 8.0.2
I have been round and round the forum answers for days trying everything but have drawn a blank.
The code in php.ini is :
> [XDebug]
; Only Zend OR (!) XDebug
zend_extension = c:\xampp\php\ext\php_xdebug-2.5.4-5.6-vc11.dll
xdebug.remote_autostart=on
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9001
xdebug.remote_handler="dbgp"
xdebug.profiler_enable=1
xdebug.profiler_output_dir="c:\xampp\tmp"
xdebug.remote_mode=req
xdebug.idekey="netbeans-xdebug"
I have tried every combination of parameters for the above imaginable.
The port I have used in netbeans is:
project properties > Run Configuration > Advanced: 9001
Netbeans > Tools > Options > PHP > Debugging : 9001
Could it be significant that the debugger is using the Chrome browser, but my phpmyAdmin and the home screen for XAMPP are on IE?
I'm not sure about Windows, but in later versions of PHP on linux (starting from at least 5.4) the xdebug configuration is in a separate file. Mine is in:
/etc/php/7.0/apache2/conf.d/20-xdebug.ini
If you don't have a dedicated xdebug ini file, make sure you are editing the right php.ini. In my system there are 3:
/etc/php/7.0/apache2/php.ini
/etc/php/7.0/cli/php.ini
/etc/php/7.0/phpdbg/php.ini
Here is my xdebug configuration:
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.show_local_vars=on
A few considerations:
I see your port is different from mine (9000 vs 9001). Go to Tools->Options->PHP, at the "Debugging" tab make sure the "Debugger port" corresponds to the one specified in xdebug.remote_port.
Try to use localhost instead of 127.0.0.1
Make sure the output of phpinfo() contains information about xdebug. If you don't have an "xdebug" section you probably need to check the zend_extension path.
I remember reading on the NetBeans mailing list that a few people had problems caused by the Windows firewall, maybe you can try to disable it.
A lot many people facing the same problem. This awful error/bug seems from Netbeans itself not from X-Debug. I also faced the same problem with Netbeans.
Your php.ini file configuration looks fine. Try #paolosca's answer. If that didn't work try the below suggestions.
After right click on your project name in Netbeans and select Properties -> Run Configurations
Now you'll see project run configurations. There select index file (Ex, index.php) then in Arguments field pass
XDEBUG_SESSION_START=netbeans-xdebug
as argument to index.php file. That you should start debugging the PHP code.
If you think it's a long way you can directly pass the arguments as below. Say you have the url like,
http://localhost/foo-project/index.php
then pass the argument like this in browser's url window
http://localhost/foo-project/index.php?XDEBUG_SESSION_START=netbeans-xdebug
and hit Enter.
To answer your last question
Could it be significant that the debugger is using the Chrome browser, but my phpmyAdmin and the home screen for XAMPP are on IE?
I don't think so.
This might help someone in the future, if the above did not help. Turn off the "Personal Networks Firewall" in Windows Defender in Windows 10:
Control Panel\System and Security\Windows Defender Firewall
After spending hours and hours trying everything without success, this finally did it for me...!

Netbeans and PHP - Remote Debugging, Not Hitting Breakpoints

I am attempting to debug a site (hosted on a remote server) from my local machine. I have xdebug installed on the remote machine and enabled remote debugging and auto start options for the xdebug extension.
In some ways it appears to make a connection, the site loads fine, the "debug" icon to right of the browser's search bar is highlighted, and the "styled" error messages even appear. However, it absolutely will not stop at any breakpoints.
I would greatly appreciate any guidance.
Relevant parts of php.ini (on the remote server)
; This setting is on by default.
report_zend_debug = 1
zend_extension = C:\Program Files\PHP\v5\ext\php_xdebug-2.4.1-5.6-vc11.dll
[PHP_XDEBUG-2.4.1-5.6-VC11]
xdebug.remote_enable=1
xdebug.remote_autostart = "On"
xdebug.remote_port=9000
Previously, before I put the applications on a remote server, the debugging worked fine. I have done some looking around and reading up on how it should be done, but with no success.
A few things I noticed that could solve your problem:
First of all there are usually no spaces between the key and the value in .ini files. I'd recommend to remove them since this might cause problems. Furthermore, remote_autostart expects a boolean, not a string. Change it to
xdebug.remote_autostart=1
You also need to tell Xdebug where the debug client is running, so add:
xdebug.remote_host=<ip.of.your.local.machine>
Another option would be to set xdebug.remote_connect_back=1 instead, which is simpler but also less secure (since anybody who can connect to the server can run a debug session). So if possible use remote_host.
Also make sure that the firewall (on either machine) is properly configured and doesn't block anything and that all Xdebug settings match with your settings in Netbeans.
Hope this helps

PhpStorm and Remote XDebug not working

I've followed multiple tutorials to set up XDebug with PhpStorm but it seems like
I'm not lucky with it at all. No matter what I try, it's always stuck with
Waiting for incoming connection with ide key 'PHPSTORM'
But when I reload the page with CTRL + R I can see for a split second connected.
However, then it switches back to "Waiting.."
I've tried the XDebug Chrome Plugin and the PHPStorm XDebug Generator Bookmarks
aswell as enabling "Start listening for PHP Debug Connections" in PHPStorm.
I'm Using NginX with php5-fpm and tried tcpdump 9089.
As said, for a split second it dumps it. But then it's lost again..
Can someone please help me?
My php.ini config :
[xdebug]
zend_extension="/usr/lib/php5/20121212/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port=9089
xdebug.remote_connect_back=1
xdebug.profiler_enable=1
xdebug.profilter_output_dir="/tmp/xdebug.log"
xdebug.idekey=PHPSTORM
My PHPStorm Settings :
[
EDIT : I have NO IDEA why, but removing xdebug.remote_connect_back=1
and replacing it with xdebug.remote_host=my.ip.add.ess made it work?!
As I've read the docs I had the understanding that the first setting is for implicit requests
while the later one is for an explicit ip request..
Give the following setting a try, sounds funny but just copy past the entire block instead of typing them in (believe you me that helped a couple of colleague of mine)
xdebug.remote_host=10.0.2.2
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.show_exception_trace=0
xdebug.show_local_vars=0
xdebug.var_display_max_data=10000
xdebug.var_display_max_depth=20
xdebug.max_nesting_level=200
p.s.
I assume you have the extinction file is exists in your guest machine (Virtual Machine) since you said it will stops at the breakpoint for split of sound
Also i assume your browser is sending the correct "PHPSTORM"

XDebugging a website with Eclipse/PDT while PHP and the website-files are located on another server ... how?

Following situation:
Windows 7 running on my PC.
Also Eclipse with PDT and VMWare, which is my 'server'.
Within the VM I have Debian 5 running, Apache, PHP + XDebug and OpenSSH-Server.
I can connect to Debian with Putty using the IP 192.168.0.128 and Port 3128.
On my Win7-host there is no PHP available.
How can I get Eclipse to connect with XDebug on the VM?
I'm a bit lost here, 'cause I seem to lack some necessary network-basics. Could someone please give me a hint which 'combination of words' will lead me to the solution using Google, usually that's all you need Google + 'the right words' ... tunneling? remote? ... all lead me astray so far.
Thanks
Raffael
In php.ini on your Debian virtual server, XDebug should have some configuration variables set up. one of them is xdebug.remote_host. It is probably set to "localhost" right now. It needs to point back to your Win7 PC's IP address.
In php.ini (make sure you are editing the one that Apache is using, not the one that PHP CLI is using...they may or may not be the same):
xdebug.remote_enable=on
xdebug.remote_host=192.168.0.999
Where 192.168.0.999 is replaced with the PC's IP address.
You need to make sure that xdebug.remote_port and xdebug.remote_handler are set to the value that your Eclipse plugin is expecting too.
An alternative to specifying an xdebug.remote_host would be to use xdebug.remote_connect_back. I've never set that up, so I can't help you more than point you XDebug's docs.
Note that you may need other php.ini settings to set yourself up properly. I'm not an Eclipse user, so I'm not familiar with its special needs (if any). The XDebug docs or the documentation site for the Eclipse plugin you are using will probably have a basic installation and requirements guide for you.
If you are not sure which php.ini Apache is using, create a php file with phpinfo(); in it (and nothing else, other than <?php to start things out), and then access that file using your browser through the Apache server (drop it in the root directory of the web server). Look for "Loaded Configuration File"... should be near the top.
thanks for the effort.
For the archive, my configurations:
xdebug.ini:
xdebug.remote_autostart = Off
xdebug.remote_enable = On
xdebug.remote_mode=req
xdebug.remote_host=[HIP]
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_log=/var/log/apache2/xdebug_remote
xdebug.profiler_enable = 1
[HIP] you get through netstat, in my case it's the (only) SSH conncetion, b/c of putty.
php.ini:
zend_extension=[path you find in xdebug.ii]
Eclipse:
Debugger: XDebug
Server: IP of VM
That did it for me, basically.
Best
Raffael

How to debug PHP with netbeans and Xdebug

I have recently tried to get going with Netbeans 6.5 after it rated so highly in the IDE review by Smashing magazine. http://www.smashingmagazine.com/2009/02/11/the-big-php-ides-test-why-use-oneand-which-to-choose/
My main reason for switching from Notepad++ is that I'd like to be able to debug my code and set through it.
I have followed the instructions about how to install xdebug from both the vendor http://xdebug.org/ and the netbeans web site. http://www.netbeans.org/kb/docs/php/debugging.html#gettingReady but to no avail.
How is it done, has anyone else got debugging working in netbeans?
(My setup is: Windows XP, Wamp server 2.0, PHP 5, Netbeans 6.5.1)
It's important to add this line in the php.ini:
xdebug.idekey="netbeans-xdebug"
Note: In NetBeans go to Settings and look where the xdebug stuff is set up. Look for that Session ID. In my case it was netbeans-xdebug.
hm, for me, the netbeans was the first ide that php debugging was working out of the box.
Does the xdebug show in phpinfo? if it does it should work with default settings. the only one that is needed is:
xdebug.remote_enable=on
So if this isn't enabled put it in your php.ini file, restart apache, and debugging should work.
If not, you will have to supply more info for me to help you.
sy
I have since found that WAMP, when installed with Mod_rewrite and cURL cannot cope with Xdebug.
It is a known error and crashes everytime.
http://phphints.wordpress.com/2008/10/24/wampserver-phpini-settings-for-use-with-xdebugdll-pear-and-silverstripe-cms-framework/
Unfortunately, I am using these 2 libraries too.
It's not a know problem that xdebug gives issues with curl or mod_rewrite. The only issues I am aware of is with Xdebug on Vista.
You can see here:
http://ruilima.com/2010/11/ambiente_de_desenvolvimento_php_netbeans_xdebug/
is in Portuguese, but there is a pre configured virtual machine with Ubuntu 10.10, netbeans, php, mysql, xdebug, ready to use. take a look
I found out that in Netbeans you need to set the webroot path in the projects to app/webroot. If you do this debugging works flawlessly.
If you are using xampp under Windows:
You only need to open your php.ini file and change these two lines
;xdebug.profiler_enable = 0
;zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
into
xdebug.profiler_enable = 1
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
(Caution: If your xampp version is old, you must download it from http://xdebug.org/download.php, download the 32 bit even your OS is 64 bit. E.g. the xdebug's name you downloaded is php_xdebug-2.2.1-5.4-vc9.dll. First copy php_xdebug-2.2.1-5.4-vc9.dll to the directory C:\xampp\php\ext\, then your the second line will be zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.1-5.4-vc9.dll)
After that stop apache and start again, that's it.
If you're having the problem in which Apache decides to crash whenever you run the debugger (which is what I had and is extremely annoying). I'm fairly sure I re-installed xampp and re-set up xdebug. I think the problem was to do with the zend-debugger being set up weirdly in php.ini and me not modifying the correct php.ini.
Eventually after re-installing and resetting it up I got it working fine.
I now run a dev release of Netbeans which has networked debugging with xdebug so we run it all off of our development server and it works a treat.
Good Luck, There isn't particularly any decent documentation on how to set up xdebug with net beans.
I have had occasional issues with NetBeans and XDebug which have been down to a Watch statement being in place which does not relate to the code being debugged.
In this case the debugger just fails with a Socket Exception.
Remove any watches if you find this is causing your issue. Generally though I have found XDebug to be extremely handy!
I do realise however that this may not relate to the issue you have here but it's worth being aware of.
found the solution of the same problem on the same site PHP Netbeans: xdebug stops on every include() or require()
Well wrongdoing was, forgetting
[xdebug]
as a section header in php-ini. And of course, "park" your stuff right before another section start (e.g. [Date] or [iconv]) otherwise you will accidetenly place those in the wrong section. (In the comment djungle of php.ini this happens easily.)
In my case it was a process running on my machine (Windows 7) that was using port 9000 already called aeagent.exe
I changed my php.ini setting to "xdebug.remote_port=9001", made the corresponding change in netbeans, then restarted Apache. Now it works.
Thanks to SysInternals TCPView tool.
Go to http://wiki.netbeans.org/HowToConfigureXDebug . There is a big list of steps you should follow, that might help you out.
But most likely you just need a new version of xdebug-binary. Go to http://xdebug.org/wizard.php to find out what binary you need und your problem might be solved.
When running netbeans under Ubuntu, I was facing this issue too, it seems that I have tried all solutions found in internet but all in vain.
The only thing that finally helped was running netbeans with SUDO command! Looks like regular user didn't have permission to listen on port 9000 (or any other).
sudo netbeans &
...and voila, I can debug again! Maybe it'll save you a day or two
Now its working after Wasting the 3 hours for making xdebug work on Windows8 with wamp 2.2
replacing original lines below [xdebug] with following
zend_extension = "c:/wamp/bin/php/php5.3.13/zend_ext/php_xdebug-2.2.0-5.3-vc9.dll"
;make sure path of your own php_xdebug, dll version may vary.
[xdebug]
xdebug.remote_enable = on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
;recheck your port number in netbeans [Tools=>options=>php=>debugging there it is: debugging port]
xdebug.profiler_enable = on
xdebug.profiler_enable_trigger = on
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
Now click on wamp icon in taskbar and "restart all services"
Well..Now final step>>START NETBEANS AS ADMINISTRATOR
Holly soul of windows8 i hate you :<
Go through the below document for remote debugging using NetBeans.
http://stuporglue.org/setting-up-xdebug-with-netbeans-on-windows-with-a-remote-apache-server/

Categories