The administrator has installed Xdebug 2.1.1 in our shared PHP 5.3.0 server in order to use its debugger. Now, I can hardly read the stack traces of uncatched exceptions because they are formatted by Xdebug with annoying colours that interact badly with the site's CSS:
Since PHP runs as Apache module, I've tried to disable this feature in an .htaccess file but I can't make it go:
php_flag xdebug.default_enable Off
php_flag xdebug.overload_var_dump Off
php_flag xdebug.show_exception_trace Off
php_value xdebug.trace_format 1
phpinfo() shows my changes in the Local Value column but I can still see those horrible orange tables. What's the directive I need to change?
Check for xdebug_disable()Docs:
Disables stack traces
Disable showing stack traces on error conditions.
See as well xdebug.default_enableDocs.
You need to make sure you have html_errors=0 in PHP as well.
Also, orange isn't horrible ;-)
Add following code in the initialization Script:
if (function_exists('xdebug_disable')) {
xdebug_disable();
}
Related
I have a new IIS 10 / Server 2019 server, which uses a SMB file share for app data. My problem is, for PHP sites there is a delay of about 2 minutes and 15 seconds for a simple "hello world" website to start. Even stranger, it does it on all sites with PHP 7.x, but not on 5.x unless it's a more complicated site like Mediawiki. It also only does it when loaded over the fileshare, which is otherwise quick to access. Once loaded the first time it runs quickly for about 3 min until whatever loaded process has to reload from scratch again. Using the error log, I can see that PHP loads the ini instantly and will complain about formatting errors and such right away, but the first line of a php page does not load until the last second. PHP xdebug also doesn't seem to note anything until the last second of loading.
It certainly seems like something is trying to resolve and timing out, but using //192.168.1.x doesn't work any better than //fileshare. I've poured through the php.ini looking for a culprit but can't find it. Any help is greatly appreciated!
The main settings I've messed with are the ones below with different combinations and ways of writing the path.
cgi.force_redirect = 0
cgi.fix_pathinfo = 1
fastcgi.impersonate = 1
fastcgi.logging = 0
track_errors = Off
soap.wsdl_cache_dir = C:\inetpub\php_temp
error_log = "C:\inetpub\php_errors\php_error73.txt"
upload_tmp_dir = C:\inetpub\php_temp
sys_temp_dir = C:\inetpub\php_temp
session.save_path = C:\inetpub\php_temp
Managed to trace it down to two odd culprits.
The main time out issue was:
user_ini.filename =
By default it's commented out in php.ini, so removing the semi colon disabled that feature which must have had trouble searching for ini files on the file share.
Second issue on 5.x seemed to be related to having the old mysql plugin enabled. Leaving it enabled didn't seem to matter on local disk, but having it enabled caused issues on the file share. I'm using mysqli in code, so no problem disabling it for me.
I've installed PHPStorm (8) and trying to debug WordPress theme using xDebug. I tried chrome browser extension and some other settings in the PHP Storm settings.
I've searched a lot but still unable to attach the page to the debugger. What I want is to run the code line by line and check variables etc.
Can someone tell me what exactly is required so the debugging works?
I've following structure:
WAMP is at: c:\wamp
Project is: d:\projects\test
alias is: http://localhost/test/
When I opened the project in PHP Storm. It identified it as WordPress project. But it never attaches the browser to debugger.
Edit
Here is the related xDebug code in php.ini
zend_extension = "c:/wamp/bin/php/php5.3.13/zend_ext/php_xdebug-2.2.0-5.3-vc9.dll"
[xdebug]
xdebug.remote_enable = 1
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.remote_port = 9000
I also tried true instead of 1. Also tried without providing any port.
There seem to be a lot of ways to set up debugging. There are browser plugins, and bookmark commands, and all sorts of elaborate setups.
For the most part, I always want debugging enabled while I'm developing. If that's true for you, you might consider adding this to your php.ini file:
xdebug.remote_autostart = 1
In addition, a key part to my setup is that I have to click the button in the toolbar for "Start Listening for PHP Debug Connections", and keep this enabled while I work. This is also in the menus under "Run".
Have you tried zero-configuration guide for PhpStorm debugger?
https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm
I'm using this solution and it works fine.
Don't forget to add breakpoints and I recommend to create the bookmarklets to activate/deactivate debugger cookies in browser (https://www.jetbrains.com/phpstorm/marklets/).
I'm not sure why, but xdebug does not highlight var_dump(). But config seems to be fine. Have no idea why... Any suggestions?
This is my phpinfo(); http://pastebin.com/A45dqnWN
plus even xdebug_var_dump() doesn't highlight anything. It works, but look like normal var_dump().
I found that option "xdebug.default_enable Off Off" in you php_info(). I also have noticed that in last versions of EasyPHP this option is turned off. So turn it on by setting this line in php.ini:
xdebug.default_enable=1
Next is just common operation which disables var_dump and other errors in HTML output completely (not your case, but maybe helpful for others):
html_errors = On
For Xdebug 3 you need to enable develop mode in your php.ini:
xdebug.mode= develop
You can also use multiple modes at once as explained here.
The following values are accepted (for xdebug.mode):
off
Nothing is enabled. Xdebug does no work besides checking whether functionality is enabled. Use this setting if you want close to 0 overhead.
develop
Enables Development Helpers including the overloaded var_dump().
coverage
Enables Code Coverage Analysis to generate code coverage reports, mainly in combination with PHPUnit.
debug
Enables Step Debugging. This can be used to step through your code while it is running, and analyse values of variables.
gcstats
Enables Garbage Collection Statistics to collect statistics about PHP's Garbage Collection Mechanism.
profile
Enables Profiling, with which you can analyse performance bottlenecks with tools like KCacheGrind.
trace
Enables the Function Trace feature, which allows you record every function call, including arguments, variable assignment, and return value that is made during a request to a file.
You can enable multiple modes at the same time by comma separating their identifiers as value to xdebug.mode: xdebug.mode=develop,trace.
As mentioned by #Shadoweb for Xdebug v3 you want debug to allow stopping at breakpoints, and develop to format the var_dump
The following you'll likely want in php.ini therefore:
xdebug.mode=develop,debug
As an aside, I also needed xdebug.start_with_request=yes to replace the renamed xdebug.xdebug.remote_enable=1 setting to get step debugging working in my IDE.
For php 7.0.2 and xdebug 2.4.0
xdebug.default_enable=1
+
html_errors = On
Still does not colorize xdebug_var_dump() output.
but this patch fixes my issue. It applies to the xdebug.c and xdebug_var_dump() only. I think they made a mistake that xdebug_var_dump works only if it need to be overload function.
## -2191,11 +2191,6 ##
int i, len;
char *val;
- if (!XG(overload_var_dump)) {
- XG(orig_var_dump_func)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- return;
- }
-
argc = ZEND_NUM_ARGS();
#if PHP_VERSION_ID >= 70000
Turn off xdebug.mode=debug in php.ini like
;xdebug.mode=debug
and restart Apache.
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.
So I have Xdebug enabled on my local version of PHP, and I'm wondering if anyone can give me an answer as to why the output isn't styled in the default way (with the orange background, table design). I can see the stack trace and everything, but it's all just text, no html wrapper around the message.
Thanks if you have any advice to give!
BTW, this is in my php.ini file:
zend_extension="C:\php\ext\php_xdebug.dll"
xdebug.show_local_vars=On
xdebug.dump.SERVER=*
xdebug.dump_globals=On
Make sure to have :
html_errors = On
set in php.ini
As I have answered in duplicate question:
For Xdebug 3 you need to enable develop mode in your php.ini:
xdebug.mode= develop