Enable Debug Mode in XenForo for Admin
Uncategorized

Enable Debug Mode in XenForo for Admin

What is Debug Mode in XenForo?

 

Debug mode as the name suggests opens up an option to debug issues related to page loads time with the explanation of all the queries executed in rendering the output. It can immensely help to optimize SQL queries.

debug Mode in XenForo-analysis

And helps in creating a XenForo add-ons with an extra development tab under the admin area.

debug-xenforo-admin-panel

And if you don’t have the debug mode enabled, you may not be able to edit the master templates, admin templates or even edit the template modifications from other addons and can only enable/disable each template modifications.

How to Enable Debug Mode in XenForo?

Enabling debug mode in XenForo is very simple and all you have to do is add the following line of code in the config.php file under the library folder of the forum root directory.

<?php
//* Do NOT include the opening php tag above. Copy the code shown below.
$config[debug] = true;

 

Note: This may be good for a development environment or staging environment but it may not be ideal to enable debug mode on a live site for everybody.

Addon to Enable Debug Mode in XenForo

If you aren’t comfortable adding that line of code in the config.php file, there is this addon that can do exactly the same thing for you.

 

Enable-Debug-via-xenforo-Admin

Now clicking the checkbox is good enough to enable the debug mode.

On a live site, only for few minutes, enabling debug mode via an addon is convenient instead of opening up an FTP program, browse to the library folder to locate the config.php file, open up to edit the file in an editor and then upload the file using the same FTP program. Once you are done with the debug options, you may again want to undo the config file changes and resave it.

Using add-on is as simple as clicking a checkbox and then unchecking it.

Note: The addon like config file will enable the debug mode for anyone visiting the site and does not take into account any conditional enabling of debug mode.

How To Enable Debug Mode Only For Selected Users and Without Any Addons?

Debug mode can’t be enabled based on admin permissions because permission set isn’t fetched when the config file is included. So restrict of debug mode for admins will be based on IP address.

Ask Google what’s your IP address or visit WhatsMyIp.org

find my Ip

Now put the following code in the config.php file to enable the debug mode for selected IP.

<?php
//* Do NOT include the opening php tag above. Copy the code shown below.
// Add here your ip.
$debug_ips = array(202.71.5.115);
//For multiple IPs Use this
//$debug_ips = array(‘202.71.5.115′,’SOME.OTHER.IP’);
if(!empty($_SERVER[HTTP_X_FORWARDED_FOR])) {
$ip_address = $_SERVER[HTTP_X_FORWARDED_FOR];
} else {
$ip_address = $_SERVER[REMOTE_ADDR];
}
if(in_array($ip_address, $debug_ips))
$config[debug] = true;

Change the IP address to your IP address. If you wish to enable debug mode for multiple IP addresses, use

<?php
//* Do NOT include the opening php tag above. Copy the code shown below.
$debug_ips = array(‘202.71.5.115′,’SOME.OTHER.IP’);

Add every IP as comma separated string to enable debug mode for each of the IP address.

Leave your thought here