Having difficulty configuring php debugging using netbeans - php

UPDATE 2:
Nevermind, figured it out, in netbeans I had an extra ) in tools > options > general > web browser > edit > arguments was -remote {url}), so I changed it to -remote {url}.
I now have netbeans debugging php on my new laptop.
UPDATE 1:
I've been comparing my old laptop with my new laptop as debugging works on my old laptop. The only difference I have seen is the url in the browser when I click debug.
Old laptop:
http://localhost/PhpProject1/index.php?XDEBUG_SESSION_START=netbeans-xdebug
New laptop:
http://localhost/PhpProject1/index.php?XDEBUG_SESSION_START=netbeans-xdebug)
When I remove the ending ) from the new laptop url manually, debugging starts to work... Why does the new laptop setup have an ')' at the end and the old setup doesn't?
ORIGINAL QUESTION:
I'm trying to configure xdebug for php debugging via netbeans on a localhost. I have tried following a couple of guides, but can't seem to get it to work. I've had it configured on an old laptop, but can't seem to remember how. At the moment, when I add a breakpoint and click "debug project", it opens up a browser and displays waiting for connection (netbeans-xdebug). The "step over" and "step into" options are disabled.
How do I resolve this issue?
I have done the following so far:
I have installed lamp, php5-xdebug, and the php plugin for netbeans.
I have the following in /etc/php5/apache2/conf.d/xdebug.ini:
zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_enable=1
I have done service apache2 restart.
I can see that xdebug is enabled with phpinfo();
In netbeans - tools > options > php, I have done the following:
PHP 5 Interpreter = /usr/bin/php
Bebugger Port = 9000
Session ID = netbeans-xdebug

Sounds like netbeans is waiting for php to callback. Did you add xdebug to php?
For more info see this article

The solution to the problem can be seen in update 2 in the original question, which is:
In netbeans I had an extra ) in tools > options > general > web browser > edit > arguments was -remote {url}), so I changed it to -remote {url}.

Related

Debug PHP 5.6 with PhpStorm and Zend Debugger

I'm using PhpStorm 2017.2.4, and programming with PHP 5.6 (for technical purposes).
Because I'm using PHP 5.6, since Xdebug only supports PHP 7 and upwards, I cannot use it to debug my code - hence I have to use Zend Debugger.
I've been trying to attach Zend Debugger to PhpStorm by following this video, though it doesn't seem to work.
I'd like to be able to debug PHP similarly to how I'd debug JavaScript with Chrome Developer Tools (breakpoints, check variable values, etc.)
What I've been trying, so far:
Download the Zend Debugger ZIP, extract ZendDbugger.dll to C:\xampp\php\ext and add to php.ini:
[Zend Debugger]
zend_exxtension_ts="C:\xampp\php\ext\ZendDebugger.dll"
zend_debugger_allow_hosts=localhost
zend_debugger.expose_remotely=allowed_hosts
I tried clicking this > + > PHP Web Application > Server ... > + > Name: localhost, Host: localhost, Debugger: Zend Debugger > OK > OK
Set a break point, so I know that the debugger works > Shift+F10 > Enter an input into the text field and submit > PhpStorm's The break point isn't triggered
I thought that I may have missed a step due to PhpStorm's bookmarklet instructions, so I put the Start Debugger one, restarted the webpage, entered the input, pressed Start Debugger and submitted - but no, no breakpoint was triggered.
What have I missed?
Thanks!
you need to install a chrome extension to link your page to phpstorm debug functionality. something like this one : https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en
I came across a similar scenario and I could debug PHP 5.6 in PHP Storm with the following steps.
Installed XAMPP 5.6 via this link
It's bundled with php_xdebug.dll and therefore no need to download it from xdebug.org. In case you don't have it can be download from here.
Update php.ini by appending the following lines at the end of the file.
[xdebug]
zend_extension="C:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_enable=1
xdebug.profiler_output_dir=C:\Temp
xdebug.idekey=PHPSTORM
xdebug.remote_autostart = 1
Restart Apache Server
Install 'Xdebug helper' extension to chrome.
Now in PHP Storm click on "Start Listening for PHP Debug Connections" button and you should be able to hit your breakpoints.

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...!

Xdebug with PhpStorm IDE - detects incoming connection but will not bring up debug console

I have tried to set up Xdebug (2.2.3) with PhpStorm 7.0 and I cannot bring up the step-through debugging console as I have in the past. The guides that I have used to set this up are:
https://www.jetbrains.com/phpstorm/webhelp/configuring-xdebug.html
http://blog.jetbrains.com/webide/2011/02/zero-configuration-debugging-with-xdebug-and-phpstorm-2-0/
I know that the Xdebug extension itself is working as the cachegrind.out.3280 files are being created on page load (with 12Mb litany of all of the scripts required and variables/values). My set up in php.ini (php version 5.4.12) is:
zend_extension="c:/wamp/bin/php/php5.4.12/zend_ext/php_xdebug-2.2.3-5.4-vc9-x86_64.dll"
xdebug.profiler_output_dir="c:/wamp/tmp"
xdebug.profiler_output_name="cachegrind.out.%p"
xdebug.profiler_enable=1
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.idekey=xdebug
xdebug.remote_connect_back=1
xdebug.remote_host=dashboard.dev
After setting a break point, turning on Xdebug chrome extension, clicking to listen to Xdebug within PhpStorm and refreshing, I get the Incoming Connection from Xdebug dialogue:
However, when I click Accept, the dialogue disappears and nothing happens.
If I then go to Settings / PHP / Servers in PhpStorm, I see that a new entry has been created:
Only by deleting the entry that was added can I get the Incoming Connection dialogue to show up again when I refresh the page. I notice that the port is set to 80 so wondering if that is right since the Xdebug extension is set to run over port 9000; when I click "Validate remote environment" select deployment server, then "Validate", I get: No debug extension is loaded. So I am assuming that the problem is something related to how this is set up.
The problem was fixed by adding the break points to other parts of the code as it was not working when attached to the try clause. Additionally, here are some other tips that might be useful:
Try using a programmatic breakpoint: xdebug_break();
Check that if your php is 32bit then so is the version of Xdebug (or that they are both 64 bit).
The xdebug remote host setting relates to the server IP address (so 127.0.0.1 for local).
You need to configure the mapping between server path and local path in preferences / server
In your Phpstorm goto File > Settings > Languages & Frameworks > PHP > Debug.
Under External conections section, mark the checkbox saying
Ignore external connections through unregistered server configurations
This was fixed for me.

Xdebug And Netbeans Problem

Im trying to configure xdebug to work with Netbeans 6.9 and php 5.3
As far as i concern i have setup xdebug properly.
I can see xdebug extension from phpinfo page.
I have read other post and tried their suggestion but up to no avail
When i hit the debug button, it straight open the page in the browser and i can see message 'Waiting for connection' in the bottom pane of netbeans
Here my setting in php.ini
zend_extension = /usr/lib/php5/20090626+lfs/xdebug.so
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey="netbeans-xdebug"
Any help would be appreciated
First, check that it isn't actually working for you, and you don't notice. I've done this...convinced it's not working I wasted a chunk of time trying to get it to work, only to find that everything was OK.
Look at your NetBeans status bar. If you see "netbeans-xdebug" and "running" then it is actually working just fine. You probably have the "Stop at first line" option turned off and you didn't hit any breakpoints you set (if any) yet. That would be a reason you are seeing the page with little or no indication that the debugger is actually connected.
If you instead see "Waiting for Connection (netbeans-xdebug)" and the progress bar is cycling, then you are indeed not connected. Open Tools|Options, and go to the PHP page. On the general tab, make sure that the "Debugger port" is 9000 and the "Session ID" is "netbeans-xdebug". You may want to have "Stop at First Line" checked. I don't, as I find it a bit annoying. I would definitely ensure that "Watches and Balloon Evaluation" is not checked. This option causes NetBeans and the debugger to destabilize. If you need a watch, hack a local variable into the PHP code where you need it, and you'll see it on the "Variables" tab when the debugger is running. Also, confirm that file (index.php) is specified in the project's Run Configuration > Index File.
Since you see xdebug in phpinfo(), that end of it is fine. Just make sure that all of the values look reasonable, and that there is some reference to a cookie "XDEBUG_SESSION=netbeans-xdebug" somewhere on that page. (Make sure that you don't have cookies turned off on the browser!)
The only other thing to check is to see if some firewall/security program is running that would be blocking TCP/UDP locally (which would be super-odd, but not out of the realm of possibility), or that port 9000 isn't already used by another application. I am using a different port number in my local setup for some reason. I don't remember changing it, but I am sure that the only reason I would have is if I had hit a port conflict with something else.
One last thing... We've been assuming that you are running NetBeans and the web server on the same computer. That's a common configuration, but not the only one. If your web server is on a different computer, then change the localhost in xdebug.remote_host=localhost to the IP address of the computer on which NetBeans is running.
Another last thing: When cycling through frustrating iterations, until you see xdebug info in phpinfo(), restart apache/php. Once there, still restart NetBeans between iterations. And believe it or not, restart your browser.
For me it was changing
;xdebug.remote_enable = 0 (default value in clean XAMPP installation)
to
xdebug.remote_enable = 1
did the trick
Adding an index.php did the trick for me.
I couldn't figure out why some of my projects would connect to the debugger and others wouldn't. Then I realized that the ones that wouldn't connect started with index.html. Once I renamed these files to index.php, the debugger connected with no problem.
I solved this using a windows -> remote LAMP server config after reading the following post, leaving the link in case anyone finds it handy:
http://stuporglue.org/setting-up-xdebug-with-netbeans-on-windows-with-a-remote-apache-server/comment-page-1/#comment-6227
Having just upgraded to the new Ubuntu 14.4 my NetBeans Xdebug stopped working. I've followed all the answers above to date to no avail.
I found a NetBeans Ubuntu statement that the /etc/php5/cli/conf.d/xdebug.ini file should have xdebug.remote_enable=on. When I checked the /etc/php5/cli/conf.d directory, I found no xdebug.ini file. However there was a link to /etc/php5/mods-available/xdebug.ini there.
Subsequent adding the xdebug.remote_enable=on to that file fixed the problem.
PS - This works on NetBeans 8.0.1
When I tried to debug the Yeoman WebApps powered by PHP backend in Netbeans, the status keep showing 'Waiting for connection'. There's probably because the index.html has nothing to do with php at all. It's only when I've triggered the ajax which needed PHP processing, the connection with xdebug immediately connected and debug as usual. Hope this give another perspective to someone as I have stumbled to 'think' there is a problem and trying to fix the ini.
An alternative is the Dephpugger project. Is like ipdb in python or byebug in Ruby.
https://github.com/tacnoman/dephpugger
Is very easy to use.

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