Xdebug is not working despite phpinfo() is showing Xdebug section and in VS Code the red point is displayed and the control panel. Also the debug console is started as well.
I've tried to reinstall it again. I removed Apache and install XAMPP and then install Xdebug there.
There is currently an issue with Xdebug 3.2 on Windows (specifically Apache) where it enables all features even when not requested. It is possible that this also affects other functionality like breakpoints. Until this is fixed, I recommend to use Xdebug 3.1.6, which you can still find on the historical downloads page.
However, if you use xdebug_info() instead of phpinfo(), Xdebug will tell you what it tried to do (if anything at all) to connect to the debug client. There might be hints in there too.
Related
I have Ubuntu 18.04, XAMPP, PHP 7.3.0 and I tried installing XDEBUG using the XDEBUG wizard after pasting the output of my phpinfo() and added the location of xdebug.so in the php.ini file. But still php -m doesn't show XDEBUG. Can someone please help to figure this out? Let me know if anyone successfully implemented this with PHP 7.3 XAMPP and XDEBUG.
XDebug does fully support debugging for PHP 7.3 and XAMPP. I tested it just now again with the latest version of XDebug (2.7.1), PHP 7.3.0 and XAMPP.
At first, it didn't work for me either (except in my first line of code, but it didn't stop in other lines). It was similar to the problem discussed here which was caused by an old version of IDE. Updating my PhpStorm IDE fixed the problem (This problem and fix was only for PhpStorm IDE).
Therefore, if you are using PhpStorm, follow these steps:
Update your PhpStorm to the latest version. I updated it to 2019.1 version and it works fine.
Wait until indexing is done.
Enable accepting debugging, from the top-right button. Image
PS. You should add more details to your question, such as IDE, IDE version, what you have done already, and your debugging settings.
php -m is a terminal command. Be aware that sometimes CLI PHP will use a different ini file than that of your web server PHP.
So you can check which ini files were loaded with this command:
php -i | grep ini
Check you have XDebug installed by checking phpinfo() in your browser. If it is using a different ini, and you want xdebug available in the CLI, copy the ini settings from this one to the one the terminal told you.
Once you know, check the port in your IDE matches the settings the wizard gave you for your ini. PHPStorm for instance defaults to 9000, but if you use PHP-FPM then it uses 9000, meaning I had to make my debug port 9001 and change it in the IDE too.
Make sure the IDE is listening for incoming connections (PHPStorm has a little telephone type icon which will be either green or red)
Make sure you have set a breakpoint in your code. It's a good idea to try it on the first line. Just click to the left of the line of code next to the line number, and you should get a red spot indicating your breakpoint.
Finally, ensure you are sending the XDebug header with your request! I use a browser extension that allows me to enable/disable at the click of a button. Here's one for Chrome! https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en
I'm new to VS Code and the php world. My experience is more with heavyweight IDE such as Visual Studio. However, I have a need to setup a php environment on my dev machine and am having some trouble getting it to work properly.
My environment is a Win 10 dev machine. I am using VS Code and php ver 5.5. I have properly installed the xdebug extension and verified it is properly installed. I have also installed the php-debug extension in VS Code.
The challenge I'm having and have been unable to find any useful information through google is launching the php website from within VS Code and then being able to debug it.
A few things I have tried, but haven't worked.
I installed the iis-express extension to VS Code which allows for running any folder through iis express. https://marketplace.visualstudio.com/items?itemName=warren-buckley.iis-express
This works, but the website doesn't display properly. IIS returns an error message saying the site is not properly configured. It's apparently missing a mapping or something along those lines.
I followed this blog. http://blog.denouter.net/2015/05/run-php-from-visual-studio-code.html and am able to run the website using the built in php web server.
Installed webmatrix and let the windows platform installer correctly install and wire up iis express to work with php. The same folder works fine when running from webmatrix.
Installed the php-debug extension to VS Code. https://github.com/felixfbecker/vscode-php-debug
Here is what I think I'm missing. I believe I need to launch the website from within VS Code for the debugging to work. I can't figure out how to "launch" the php website from within VS Code. The php-debug extension from VS Code only supports launch. It doesn't support "attach" mode. I suspect this is why when I run the website outside VS Code, the debugger doesn't work. Let me be clear, the debugger is working when I hit F5, it just doesn't ever stop on any breakpoints.
To summarize: How can I launch and debug my php website from within VS Code? I'm looking for a detailed step by step guide.
Thank you
I am the author of vscode-php-debug. You do not need to "launch the website" from inside VS Code. When you start the "Listen for XDebug" configuration from the debug section, VS Code (or rather, my debug adapter) will listen on port 9000 for XDebug. You need to run a web server like Apache, IIS or nginx locally on your PC and configure it to serve PHP files - this has nothing to do with VS Code. Then simply open a web browser and navigate to localhost and XDebug will connect to the debugger, stopping on breakpoints.
The two necessary settings in php.ini are:
xdebug.mode = debug
xdebug.start_with_request = yes
(Do not forget to add the subtitle [XDebug] before the settings.
i have tried to install xdebug on my mac using home-brew everything seems alright, with no errors, but when i execute phpinfo method i don't find debug module there, i have tried million times with no success, so i have read an answer here in StackOverFlow for the same reason which suggests follow these instructions http://xdebug.org/wizard.php i have copied all code source of phpinfo page, and they gave me detailed instructions, i have followed there guide with no errors after restarting my server and refresh phpinfo page, and still no xdebug !!
php.ini - http://pastebin.com/RLyzXJ9z
phpinfo() code source - http://pastebin.com/H8XVX5GG
Based on your comments, the version of Xdebug isn't the one that matches the version of php running in either your Apache mod_php or your php-fpm (if you're on nginx).
I'm guessing if you used brew, your CLI php is really in /usr/local/something... and that matches the version for your xdebug. On the other hand you whatever PHP flavor you're using for your webserver to work with is different.
My vote would be to ditch the local php or brew installed version and use something like MAMP that runs 100% it's own libraries. Adding Xdebug to MAMP is pretty well documented if you google for it.
By choosing Break at First line, the debugger gets active when entering each file, allowing me to step in and out of the code.
But it is a bit cumbersome having to tab your way through half a million steps to get to the point where it starts to get interesting.
My setup is WIMP Window 7, PHP 5.3
; xDebug config
zend_extension = "C:\Program Files (x86)\PHP\v5.3\ext\php_xdebug-2.2.1-5.3-vc9-nts.dll"
xdebug.remote_autostart=0;
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
I have made sure that the path mapping is correct.
But could it be because i'm linking to the PHP files from my Eclipse project?
After downloading Eclipse Juno i'm able to stop at breakpoints.
I have tried everything with Eclipse Indigo.
Version: 3.7.2
Build id: M20120208-0800
Just wont work, either with an internal or external browser.
Time to move on to Juno i guess?
Eclipse has an option to turn off "break at first line". Go to "Windows -> Preferences -> PHP -> Debug" and uncheck "Break at first line" and also to go in "Run > Debug Configurations > PHP Web Application" and unselect "Break at first line" in all the configurations. Then restart Eclipse.
For all those, that are still fighting with this problem, some handy tips.
Check which version (package) of Eclipse you have? It turns out, that Helios package has some bugs and doesn't stops on breakpoints, when you debug your application as Web Application. Debugging works only, if you run it as PHP Script. Which makes it pretty useless for debugging process.
You should consider either reverting to older Galileo Package Eclipse for PHP Developers or installing newest Eclipse Juno (or even newest developer version of Eclipse Kepler), which doesn't have PDT support build in, but you can easily add it to then, using Help > Install New Software.. (point it to http://download.eclipse.org/tools/pdt/updates/release).
These versions are reported to be able to debug as Web Application, respecting breakpoints.
Also, remember, that Xdebug must be run as Zend Extension in order to support breakpoints! In other words remove extension=xdebug.so (on Linux or xdebug.dll on Windows) line from your php.ini and replace it with zend_extension=/full/path/to/xdebug.so (on Linux or zend_extension=X:\full\path\to\xdebug.dll on Windows). Zend extensions requires full path, even if they're put into /php/ext folder, as regular PHP extensions. You'll find more info on this in Xdebug FAQ (look for an answer to "Xdebug is only loaded as PHP extension and not as a Zend Extension" question).
Here is a post describing how to get breakpoints to work with XDebug in Eclipse.
http://programmersjunk.blogspot.com/2013/05/eclipse-and-xdebug.html
I know this question has been asked before and I've looked through the responses but no matter what I do, I can't create an environment to step through my php programs.
I've downloaded the XAMPP stack, and Eclipse and enabled xdebug but nothing.
PHPinfo reports: Debug Build, No.
Does that mean that I'll never get an XAMPP installation to debug. If so is there another Windows, Apache, PHP, MySQL stack recommended?
I downloaded the Komodo IDE 21 day free trial and their wizard can't start debug either.
help
No, the Debug Build phpinfo() refers to is a compile-time switch/define that affects the way php itself is compiled. The debug build is less optimized, contains some more test code and the symbol files, used when stepping through the php C code with a debugger, are more accurate (mostly due to the less optimized code).
It does not affect the ability to add a script debugger module like xdebug. But you need a version of the module .dll/.so that is compatible with your version of php. The API version, Thread-safety "enabled/disabled" and "debug yes/no" information must match. (on second thought I'm not even sure if debug yes/no must match).
Does the xdebug section appear in the output of phpinfo()? If not make sure you've edited the right php.ini. In recent versions of xampp that should be <xampp dir>/php/php.ini regardless of whether you use php-cli or the apache module. But it used to be <xampp dir>/php/php.ini for the cli version but <xampp dir>/apache/bin/php.ini for the apache module of php.
Also check the error.log in <xampp dir>/apache/logs for error messages that might be related. Those should begin with "PHP Startup: ....error message..."
try using wamp if your using windows. It works great for me