I use WordPress with a local XAMPP server.
To debug my PHP code I use Xdebug and Visual Studio Code, but it doesn't work as I expect. When I stop the execution on line 191 and step over to line 194 I want to see the values of my two local variables $html and $rmcounter in the upper left corner at VARIABLES->Locals but there is nothing.
When I proceed with step over until I leave my rm_deug_test() function I see shortcodes.php and then everything works. I see the Locals in the upper left corner and I can hover over e.g. $tag and I see the value of this variable.
What should I do to see the values of the variables of my rm_debug_test() function?
In the meantime I found a solution that could be of interest to other programmers using wordpress xampp xdebug php and visual-studio-code: I changed the php.ini file in the folder xampp/php. I had only to disable opcache. I changed opcache.enable=1 to opcache.enable=0. Now debugging with visual-studio-code shows all local variables as soon as they are created when I assign a value.
Related
As I am using the local hosting of MAMPbut " There has been a critical error on this website" this is error is coming. What should I do?
Diagnostic steps worth giving a shot, follow from top to bottom order;
Is MAMP really running with Web server (and additionally the database server)?
Do you see the default MAMP index/home screen?
Put a simple HELLO WORLD HTML document to your project root and check if you can see it on browser
Put a simple HELLO WORLD PHP script to your project root and check if you can see it on browser
At this point, if everything above went well, it is definitely an issue with your actual PHP script, check the PHP error log file
Put an INFO.PHP PHP script at your project root and check you have all the required extensions available for your PHP project
Check if database connection is working (if required)
At this point, I cannot imagine what else would go wrong, try PHP debugger (xDebug needs to be installed with MAMP and your PHP editor may need a configuration for this) with break points and step into each line of your PHP code with debugger.
I am trying to debug my php script using PhpStorm and xdebug.
See my xdebug configurations below,
As for the breakpoints, I have added two of them to a simple script which reverses an array,
I debug using the default debug configurations,
The first breakpoint works fine and I am able inspect the variables. But I cannot seem to move the control to the second breakpoint. This is how my screen looks after moving from the first breakpoint and executing line num 14. Line 14 takes in an input from the command line,
So, I tried entering inputs in the console, (can see the 3 i entered)
The debugger looks blank,
I am getting myself familiar with php and xdebug, so I guess the problem should be something trivial. What do you think?
I'm trying to get xdebug working on my Mac. I'm using OS 10.6 with the built-in versions of Apache (2.2.1) and PHP (5.3.8). I followed the "tailored installation instructions" on the xdebug website, which basically consisted of these steps:
Build xdebug (version 2.1.3) from source
Move xdebug.so to /usr/lib/php/extensions/no-debug-non-zts-20090626
Add to php.ini:
zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
Restart the webserver.
From what I understand, that should be it. I know most people use xdebug with an IDE like PHPEclipse, but it doesn't sound like that's necessary just to get debugging output on the page. And a lot of old instructions involve installing MAMP, but it looks like that's no longer necessary.
Signs xdebug is working: When I run php -m and phpinfo() I get the expected information on xdebug. In scripts I'm able to call functions like xdebug_is_enabled() (returns 1) and xdebug_get_function_stack() (returns the stack).
Ways xdebug is not working: The main reason I installed xdebug was to get a stack trace when there's an error, and that's not happening. According to this documentation page, I should get a stack trace as long as display_errors is set to On in php.ini, (which it is). I've tried code that should evoke a warning (e.g., echo(hello)) as well as code that produces a fatal error (e.g., $x->awesomefunction() when $x isn't an object). Neither one produces any xdebug output, and the fatal error just causes the page to die silently. The test code given in the documentation I linked to also produces nothing.
UPDATE: It turns out that if I run a script with a fatal error from the terminal, I do get a stack trace from xdebug. However, it's still not showing up when I run the script from a browser
Also, regular error reporting is now broken: Previously, I'd get error output by including the commands:
ini_set("display_errors","1");
ERROR_REPORTING(E_ALL);
Now, putting those lines in my script doesn't produce any error reporting either. (in the browser. It does cause errors to be shown when I run the script from the terminal.)
So, what's wrong here? Did I leave something out of the xcode installation? Do I have a setting hanging around somewhere else on my system, suppressing errors? I've tried everything I can think of, but I'd be happy to test any ideas you have.
If it is working on console and not on browser, it's probably a xdebug configuration issue.
I'm not a Mac user, but on Ubuntu there are 2 different php.ini files, one for console and one for apache. If that's the case for Mac also, you can check if xdebug is enabled and properly set up in both php.ini files.
Also you can check the xdebug settings mentioned in the guide.
After several more hours of thrashing, I discovered that one of my test files actually was including another file that set display_errors to 0. The other test file was straight off of the xdebug site, but I think that at the time I was using it I'd introduced some other config error that prevented it from working properly. I'm truly embarrassed! Let this be today's object lesson in the importance of systematic, repeatable tests during debugging. On the bright side, xdebug is now working like a peach.
To summarize, the series of steps that worked was:
Build xdebug (version 2.1.3) from source
Move xdebug.so to /usr/lib/php/extensions/no-debug-non-zts-20090626
Add to php.ini: zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
Add to php.ini: display_errors = On
Restart the webserver.
I just installed WAMP on Windows XP. I have a simple PHP file that is crashing. I ran it from command line using php test.php.
What is the best way to debug php files? How do I display debugging info?
I looked at php.ini and it includes display_errors = On. Does this do anything?
I tried turning on XDebug from the PHP WAMP menu. This doesn't seem to do anything, besides restarting the server. Do I need to use this? How?
Thanks.
You can look at the log at c:/wamp/logs/php_error.log. If you are not sure whether your PHP log is being redirected here, check your php.ini file and search for a line like this:
;error_log = "c:/wamp/logs/php_error.log"
You may want to remove the comment on this line.
As much as i know about PHP and WAMP.I don't think there is any special debugging option available in this.for the debugging you need to print the answer using echo and exit function wherever in your code you feel the error may posible. The other option is, you need to use software which provide debugging facility such as eclipse with php.
I am using WAMPSERVER 2.4 on Windows 8 pro. I was using WAMP on localhost.
It appears that in my version of WAMP, the php.ini file had appeared as:
;error_log = "Z:/wamp/logs/php_error.log"
When in actuality,for me get the function error_log() to work properly, I wanted it to appear as :
error_log = "Z:/wamp/logs/php_error.log"
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.