Xdebug configuration - php

I am new to php and I need to use Xdebug with netbeans for a remote school purpose.
My php's version is 7.3.21 and I am using it with Wamp. Netbeans is on 11.1 version.
I installed last updates for wamp and xdebug, and the problem is when i run debugger in netbeans, xdebug doesn't load and keeps this status running :
So I investigated and xdebug seems installed as you can see here (from click on wamp -> php -> configuration) :
and here (from click on wamp -> php -> extensions) :
Everything seems ok, but still doesn't work. So I check on https://xdebug.org/wizard with phpinfo() function, pasted the return in the textarea and here's the status :
I check everything and here is my php.ini file :
In this context, using the debugger shows me infos on a html page as you can see on following image but I can't inspect my variables in netbeans because of the "waiting for connection (netbeans-xdebug)...
I tried to use "localhost" instead of my IPv4 address, and "ext" instead of "zend_ext" but the html page doesn't provide me anymore informations.
Moreover the weird thing is that when I copy-paste a php -i result in the textarea from https://xdebug.org/wizard, it tells me that xdebug isn't installed .....
I checked and tried many posts' solutions from stackoverflow, but nothing is working, I don't know what to do more, so if any of you guys could help me it would be highly appreciated.
Thank you
Edit: Thank you Arsen for the answer, I tried both of your suggestions and followed the upgrade guide but none is working . Here is my php.ini file which I modified that much that I can't even get back to the base configuration..
Should uninstall wamp and install it again ?
I have a 5.6.40 php version and the preinstalled xdebug 2.5 version is working in netbeans.
The problem is that I will have to modify an app written with php 7 and use phpUnit / phpDocumentor / codeSniffer. Do you think that working with e 5.6.40 php version would be fine ?
Again, I am new to php / wamp and all the related stuff, sorry if my questions are "stupid".

XDebug 3 is still pretty new and it appears your xdebug-configuration in your ini-file is still using the config names for XDebug 2. Luckily, XDebug provides a upgrade guide, which you should adjust your config according to.
My first guess is that you are using the wrong port, because XDebug 3 is using port 9003 by default and you are expecting port 9000 in NetBeans.
So you can either:
Listen on port 9003 in NetBeans or
Set xdebug.client_port to 9000 in your ini-file. (Rather than xdebug.remote_port, see the upgrade guide Ilinked above)
Keep in mind that you should go through the upgrade guide for all your configuration settings to ensure that XDebug is actually doing what you want it to.

Related

How to debug PHP Web Application using Aptana

This feels like a really stupid question, but I cannot find any YouTube videos / articles / guides / etc that explain the debugging process in Aptana.
I've found the ones that explain how to install the XDEBUG or ZEND components, and that's all good. Now, how do I use them? I can see all sorts of menus, server configurations, debug configurations, but I cannot find a guide that explains how to actually set about using them.
Is there some sort of "PHP debugging with Aptana for dummies" that would provide a very direct walkthrough, something along the lines of:
This guide starts by assuming you have installed XDEBUG into your Aptana studio, and confirmed it with phpinfo().
Setup a debug configuration by....
Start your debugger by ....
Step through the code by ....
and so on.
It sounds so obvious, but I cannot even find something like that for a different IDE.
Please someone put me out of my misery.
Hope this helps someone... heaven alone knows why I've battled so much with it.
I am using Aptana Studio 3, build 3.4.2.....
And XAMPP ver 1.8.1 installed on C:\xampp (on a windows machine)
1. Ensure that XDEBUG is PROPERLY installed.
I moved to a new computer, and forgot to check. :(
Open php.ini file under \php directory
Make sure the following lines are uncommented (no semicolon)
zend_extension="<Xampp_Home>\php\ext\php_xdebug.dll"
xdebug.remote_host=localhost (change 'localhost' to '127.0.0.1')
xdebug.remote_enable=0 (change '0' to '1')
xdebug.remote_handler="dbgp"
xdebug.remote_port=9000
Save and restart web server.
2. Setup your web server in Aptana under Window > Preferences > Aptana Web Studio > Web Servers.
(I use virtual host containers.)
Name: MyWebServer
URL: http://MyProject
DocumentRoot: c:\xamppProjects\MyProject\php
3. Setup the PHP interpreter in Aptana under Window > Preferences >
Aptana Web Studio > Editors > PHP > PHP Interpreters.
Add...
Name: XAMPP PHP Debugging
Executable path: C:\xampp\php\php.exe
PHP ini file: C:\xampp\php\php.ini
PHP Debugger: XDebug
Now try it out
In Aptana Studio, select the Debug perspective.
Open a browser and fire up your app (http://MyProject)
Aptana interrupts with a pop window titled "Incoming JIT debug request" and asks "A remote debug request was received from 'MyProject'. Would you like to break on the first line?"
Select yes, and you're into the debugging.
Once I got to this point, I found the setting of breakpoints and tracing the flow pretty painless.

PhpStorm debugger not stopping at BreakPoints; keeps waiting for xdebug _SESSION_

Updated question : PhpStorm | WebMatrix (IISExpress) | Xdebug.remote_port | — Which Port(s) to put where?
I'm running localhost web server on my Windows machine with WebMatrix and IISExpress. I've installed PHP and Xdebug in it and they both are working.
I have a local WordPress install.
I'm now trying to get PhpStorm to debug it using Xdebug.
When I run PhpStorm it launches the web app in the browser with relevant debugging parameters in the browser.
IDE KEY is matching
xdebug.remote_port is configured correctly. (Later I found that this is wrong, but not erroneous. It should be port 9000)
But it seems Xdebug never gets to communicate with PhpStorm. PhpStorm keeps listening, and the execution runs completely without stopping at any break-points.
These lines are crucial to make it work (in php.ini):
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
xdebug.remote_autostart = 1 # <-------- THIS
xdebug.remote_enable = 1 # <----------- AND THIS
Without these lines xdebug will never work on phpstorm ;)
Try changing the xdebug listen port in your php.ini and your IDE.
Running Mac Yosemite, for me the problem was that I installed with homebrew, following a guide that used php-fpm, which uses port 9000 by default (which conflicts with the xdebug default port)... Changing my xdebug.remote_port to 9001 and changing the xdebug port in phpstorm fixed the problem, though I suspect this issue could happen for anyone in any IDE. I googled for the better part of a day and didn't see this solution (since I believe it's so specific to install method).. but I hope it helps someone.
Took me about an hour until I noticed that this button wasn't activated ;)
"Run" -> "Start Listening for PHP Debug Connections"
First check for on what port xdebug is working on, you can find it in your php.ini under xdebug.remote_port=9123. As you can see in my case it is set to 9123.
Now open PhpStorm go to php debug, see screenshot:
under Xdebug you will find Debug port, make sure that its value is the same as in the php.ini file under xdebug.remote_port (9123 in my case).
Hope it helps
Could be a Firewall.
Day 572... Still haven't slept or eaten... But I finally found the culprit: Windows Defender!
Basically, I had a firewall blocking JetBrains IDE Support chrome extension from sending data to PhpStorm through the default 127.0.0.1:63342 address.
--- Edit
Day 864... Same issue happened again, this time on Linux... But I finally found the culprit: Ubuntu Firewall!
Seriously, this happened to me again a few months later, using Linux, and it was the firewall again. Disabling the firewall solved it sudo ufw disable - If you care for the firewall and want to keep it enabled, gotta dive in deep on creating some sort of whitelist for it.
For me it was changing the line:
xdebug.remote_host=localhost
to
xdebug.remote_host=myComputerIP
( Mac user: in terminal run ifconfig to find your ip )
If anyone else runs into this issue and is using Vagrant, this is what finally fixed it for me:
xdebug.remote_host=10.0.2.2
That needs to be the IP address of your local machine from inside the Vagrant box, and 10.0.2.2 is the default. If you ssh into your Vagrant box, it will show the IP where you logged in from if you want to confirm.
I know this isn't directly relevant to the specific setup the OP had, but this post shows up in a lot of xdebug / PhpStorm Google searches so hopefully this can help someone else.
PHPStorm has a build-in tool in Run > Web Server Debug Validation.
It helped me to solve my problem.
There was a syntax error in php.ini. There were extra "quotes" and ;colons;.
I also obtain this error message.
Also was troubles with the php.ini but more subtle.
Try to find and delete a row like this
extension=php_xdebug-...
Consider to look at my answer here for details "Xdebug - command is not available".
I was having this same problem while trying to test a Laravel project using XAMPP on Windows in PHPStorm. I have no idea what exactly I was doing wrong, but I did get it working eventually. I followed the step-by-step instructions on the PHPStorm site here.
One thing I think that was not configured right was that there was no interpreter set up in the PHP menu in Settings.
I was also trying a few too many combinations of settings in my php.ini. These were the settings that I have when things were working:
zend_extension = C:\xampp\php\ext\php_xdebug-2.3.2-5.6-vc11.dll //as recommended from the Xdebug site itself
xdebug.remote_enable=1=
xdebug.profiler_enable=1
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
In my Run/Debug Configurations, I use a PHP Web Application setting, that just starts on the root of the site. (At first, I thought the appended ?XDEBUG_SESSION_START=<xxxxxxx> was a mistake, but it is not). Hopefully that might help if someone else is facing a similar issue.
Right click "Console" tab and uncheck "Focus on startup" (as seen in below image) should do the trick
I had an issue where one project would work and not another one. I tried many different configurations and I tried looking at the logs of xdebug, etc. This fix seems to have resolved my issue:
Try setting your actual ports of xdebug to 9123 instead 9000.
The new version (9) of PHPStorm changed its default xdebug connetion port to 9123 (the PHPSTORM config, not the actual xdebug config), probably for a good reason, since having the PHPSTORM config to the xdebug default 9000 didn't work but having them set to 9123 did work and resolved the issue.
I tried any of the suggested tricks and finally I called the script by 127.0.0.1/script.php instead of localhost/script.php and bingo!
Based on peteclark3 answer:
I think one of solutions if you have multiple php-fpm versions with xdebug, like php5.6-fpm, php7.1-fpm - make sure only one is running. I had both 5.6 and 7.1 running. Then tried to change on 7.1 to 9001 port. But if I change to 9001 port in PhpStorm, then 5.6 starts not working, because it listens on 9000. So each time you change php version, then probably you would need to change setting in phpStorm. So I think it is better to have only one of php-fpm running and all php-fpm versions can use same port.
This fix is specifically xdebug working but breakpoints not working with docker
Step 1 (check if xdebug actually works):
Go to settings in phpstorm and then debug, check the box 'break at first line...'
Try again, if it breaks at first script xdebug is working
Could be the breakpoints aren't working because it can't find the file.
Step 2 (check your paths mappings are set up correctly):
Go to servers (it's below debug)
Make sure you have a server set up and 'use path mappings' selected
Below that ensure that your php files are mapped to the correct path in the docker container. In my case files were mapped to /var/www/files but actually in the container it was /var/www/app/files.

Zend Debugger with Zend Server 5.6.0 & PhpStorm 5.0

I am running Zend Server 5.6.0 which is PHP 5.4 and I am using PhpStorm 5.0. I am looking to put some profiling and debugging in place.
I have configured everything that I can see in PhpStorm, when I run the debug from the IDE it runs the script, then displays Connection with 'Zend Debugger' was not established. Validate Installation.
I have installed the toolbar but whenever I try to debug a page in Firefox it actually pops up with a download window and the file downloads, when opened it displays a server error.
All of the help guides online dont seem to work, has anyone else has these issues?
I ended up using Xdebug:
To Install Xdebug:
Go to webpage.
Paste your phpinfo() contents into the box
Follow the instructions on the wizard page except for where it tells you to add zend_extension = C:\Zend\ZendServer\lib\phpext\php_xdebug-2.2.1-5.4-vc9-nts.dll to the top!, put this below the iOnCube Loader (if you have it installed)
Add the following to php.ini then restart PHP & Apache.
php.ini
[XDebug]
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.profiler_enable=0
xdebug.profiler_output_dir="C:\Zend\ZendServer\tmp\xdebug-profiler"
Xdebug in PhpStorm
Generate and add bookmarklets to your browser here (Note the IDE key ##PHPSTORM##)
Open File -> Settings -> PHP
Choose your interpreter
Click [..]and choose Debugger: Xdebug
Click the "Configurations" then Edit Configurations... item (Drop down next to debug button on toolbar)
Press the [+] to add a configuration and choose PHP Remote Debug
Call it Xdebug and use the IDE key PHPSTORM
You can now start the debugger (Alt+Shift+F9)
Start the debugger using the bookmarklet
You can now stop through code in PhpStorm, hope this helps someone
This is happening because PHPStorm is using the binary for php found under /usr/bin this is not the same one as Zend Server uses under /usr/local/zend/bin. On some systems like Mac PHP is already installed by default under /usr/bin but it will not interact with the Zend Server/Debugger.
To fix this all you have to do is go into the PHPStorm preferences and tell it to use the proper Interpreter. Click the ... button next to the Interpreter drop down and give it the path to zend's bin directory /usr/local/zend/bin
This solved the issue with PHPStorm debugging with the Zend Debugger.

Can't get XDebug to make a connection in Vim. Getting "no attribue 'stop'" error

Judging by how many search engine hits this error message generates, I know this is a common problem, yet there aren't any helpful answers out there.
I'm trying to setup XDebug in Vim using Sam Ghods Debugger.vim script while following the instructions on How to Debug PHP with Vim and XDebug on Linux (which is a commonly referenced source on getting Vim setup with XDebug). I'm running MacVim 7.3 on OSX 10.6 and when I try to connect the debugger to the server, I get:
(<type 'exceptions.AttributeError'>, AttributeError("DbgProtocol instance has no attribute 'stop'",), <traceback object at 0x104595680>)
File "/Users/tjlahr/.vim/plugin/debugger.py", line 1078, in debugger_run
debugger.run()
File "/Users/tjlahr/.vim/plugin/debugger.py", line 928, in run
self.protocol.accept()
File "/Users/tjlahr/.vim/plugin/debugger.py", line 560, in accept
self.stop()
Does anybody have experience troubleshooting this error?
Please note that I'm not debugging over port 9000 because it seems it might conflict with fastcgi enabled in PHP. So I'm debugging over port 9001 and have changed by settings in php.ini and the g:debuggerPort variable respectively.
Thanks for your help.
I think I got it!
Can you try installing this Vim Plugin:
http://www.vim.org/scripts/script.php?script_id=2508
It seems that "AttributeError("DbgProtocol instance has no attribute 'stop'",)" is a general error.
I just installed XDebug and the debugger.vim plugin and ended up receiving this message. My problem was that remote debugging was not enabled. Build a phpinfo file:
<?php
phpinfo();
?>
somewhere in your web server directory, and check over all your xdebug configuration variables, which should be listed near the bottom of the page. On my system with xdebug-v2.2.0-dev built from the GitHub repo, xdebug.remote_enable was set to false. Pasting that at the bottom of your php.ini file and setting it's value to 1 enabled clients to connect to the xdebug session.
Also, in the xdebug source there is a directory called "debugclient", which can be used to test any connection problems. Follow the instructions in the INSTALL file in it's directory to build it.
And, one last thought, after you run the plugin script in VIM, you need to refresh the webpage you are trying to debug within 5 seconds, or else the script, acting as a client, will timeout.

Can't get Xdebug to work on Windows 7

I installed the latest XAMPP package which includes PHP 5.3.0. I am trying to enable Xdebug, but it just won't work.
Here's what I changed in the php.ini shipped with XAMPP:
; uncommented
zend_extension = "X:\xampp\php\ext\php_xdebug.dll"
; added the following lines:
xdebug.remote_enable=true
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
Apache starts fine, but when I open http://localhost/ in my browser, I get the following error:
If I click the Close the program button, the error message will reappear in a second as if it was in an infinite loop. I'd greatly appreciate any help in getting this to work.
I am running a fresh install of Windows 7 Ultimate 64-bit.
EDIT:
From the result of phpinfo():
Zend Extension Build API220090626,TS,VC6
PHP Extension Build API20090626,TS,VC6
Debug Build no
Thread Safety enabled
It's possible you have the wrong version of Xdebug. I would take a look at phpinfo() and compare the information there to the different versions of the Xdebug dll.
Specifically, you want to see if "Thread Safety" is enabled, and you need to know whether you're running a VC6-compiled PHP or a VC9 (if you're using Apache, it's almost guaranteed that you want the VC6).
Have you tried custom installation wizard of XDEBUG, it analyses your php installation and provides exact steps you need to follow
The Windows binaries generally work for every mini release for the mentioned PHP version, although the extension is built against the most current PHP version at that time. The VCx marker tells with which compiler the extension was built, and Non-thread-safe whether ZTS was disabled. Those qualifiers need to match the PHP version you're using. If you don't know which one you need, please refer to the custom installation instructions.
http://xdebug.org/wizard.php
Just paste your phpinfo out put in the text box and you will get exact xdebug dll you would need for your php
frank-ly, I also had 2 REALLY bad days, and I don't now what finally fixed it,
so here's my collection of Do's and pitfalls:
; this is the thread safe version,
; the absence of _nts_ in the dll name 'shows' this
; do not use _ts, your library won't get registered and won't show in phpInfo()
zend_extension = "D:/wamp/bin/php/php5.3.8/zend_ext/php_xdebug-2.1.2-5.3-vc9-x86_64.dll"
check your php.ini, check phpinfo() if all values (arrive)
xdebug.remote_enable = on
xdebug.remote_handler=dbgp
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
; if you have multiple virtual hosts ( like 'local.fooclient' )
; maybe using the IP is safer (for any same-machine-debugging)
xdebug.remote_host=127.0.0.1
; maybe a -much- lower port helped, 84 was free. use netstat to figure out.
xdebug.remote_port=84
; idekey! also see note below
xdebug.idekey=netbeans-xdebug
More Pitfalls:
I have seen a typo of xdebug.remote_handle (without r) several times on the web. beware.
A note on the idekey: The above idekey did show in phpinfo() as master value, BUT
was overridden with a 'local value' like MYMACHINENAME$. ==> Setting a global env var (in computer properties) named DBGP_IDEKEY and rebooting (or maybe just logging out) to (also) netbeans-xdebug helps! Again: re-check in phpInfo() it took effect.
Of course adjust netbeans-menu:options->php tab->debugging section to this port and session id.
Here is a script, to check (by php means) if that port you intend to talk to is open. (further below also in the comments, for those to lazy too type from the image)
For your browser to connect, don't start to forget (amidst frustration) to always attach the debug-starting get-argument:
http://localhost/myTest.php?XDEBUG_SESSION_START=netbeans-xdebug
On the port frontier, also this tool might help.
Quadruplecheck you are keeping VC6 and VC9 compiled versions of everything apart.
Running your whatever/path/php.exe myTest.php from the command line (once the above settings are done) might also reveal additional errors (it did, while I was tinkering with an incorrect dll).
I can recommend http://www.wampserver.com
(for personal reasons it fits me better than the popular xampp package...)
Yes, there is a known problem - is almost impossible to get Xdebug working with latest Xampp and 64-bit Vista/Win 7.
There is a bug reported with many users complaining about it.
The solution seems to be latest beta version on Xampp. It includes version 2.0.6 (dev) of xdebug and it is working just fine.
I tested it on 64-bit Vista for approx 10 days and not encountered any problem yet.
When xdebug is installed not with XAMPP, just with PHP (32bit, TS, VC6, in C:\Program Files (x86)\PHP) and Apache (32bit) on Windows 7 (64bit), in php.ini you need to specify the full path to x86 folder of Program Files like.
zend_extension="C:\Program Files (x86)\PHP\ext\php_xdebug-2.1.1-5.3-vc6.dll"
and NOT
zend_extension="C:\Program Files\PHP\ext\php_xdebug-2.1.1-5.3-vc6.dll"
This was my mistake, when changed to x86 folder, xdebug started to work perfectly. Hope this help you, too.
Like others have said, you need to match your xdebug version with your php version.
You've already matched up PHP version number, thread safety, and compiler.
If you haven't already figured it out (this is an old thread), what you're missing is the INI configuration. If you are loading a module that's thread safe, you need to use the following line:
zend_extension="C:\Path\To\The\Extension.dll"
If the module is not thread safe, then you use the INI directive you've been trying to use.
This only applies to zend_extension's and not regular extensions.

Categories