Enabling DEBUG and DEBUG_EXTRA

A brief description of debug mode and how it works.

Submitted by igorw on 23 Apr 2008, 12:47

One of the changes in phpBB 3.0 was raising the error level. Now what does this mean? It basically means that the code now has to follow a higher standard. The most significant change is that all variables have to be defined, else it will give you a notice.

Let's look at it. In phpBB 2.0, we would just do:
Code: Select all
$checkbox_enabled = $HTTP_POST_VARS['checkbox'];

In 3.0, we have to do:
Code: Select all
$checkbox_enabled = (isset($_POST['checkbox'])) ? true : false;

You have to always check existance using isset(), this is also to protect from problems with reigster_globals.

If you've been coding, you may not have gotten any errors when doing it wrongly. Now why is that? phpBB 3.0 hides them by default. There is a "debug" mode that displays them. For modding, you should always enable debug mode. Now how would we go about doing that? Open up config.php, and you should see this at the end:
Code: Select all
// @define('DEBUG', true);
// @define('DEBUG_EXTRA', true);

Uncomment those two lines like so:
Code: Select all
@define('DEBUG', true);
@define('DEBUG_EXTRA', true);

Welcome to phpBB dev world!

Now, let's take a look at what those two excactly mean.

DEBUG will add the page generation time and the number of queries to the footer. It will make PHP notices show up. It will also disable the "install exists" message.

DEBUG_EXTRA will add the memory usage of the current page load to the footer. It will also allow you to analyse the SQL by adding ?explain=1 to the url bar. DEBUG_EXTRA will only work if DEBUG is enabled.


There you go, you now know how to use phpBB's debug mode :).
 

Changelog:

by igorw on 06 Jun 2008, 10:55: moving the ?explain part to debug_extra (thanks strato)

License:

All articles in the knowledge base are licensed under the phpbbmodders beerware-nc license.

Back to category


Knowledge Base index