Last updated May 22, 2016. Created on February 9, 2011.
Edited by adamcadot, sidharrell, drupalshrek, jmcejuela. Log in to edit this page.

Set Drupal to show all errors when developing your module.

Some errors are only reported when all PHP error reporting is switched on. Without the error reporting on, you get the dreaded White Screen of Death.

Check for errors behind the scenes

As an alternative between showing no errors and showing all errors, you may wish to monitor the errors being generated by your site by running

tail -f /var/log/apache2/error.log

on your server.

Change settings in your dev site

You can show all errors by adding a few lines to your local testing site's settings.php:

ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

In addition, navigate to Administration→ Configuration→ Development → logging and errors and select "All messages". (This sets $conf['error_level'] = 2; .)

Switch on strict PHP error reporting

Or you can go through your development site's php.ini file, in the php folder, and switch all error reporting on. To do this, check through your php.ini file and set error reporting to E_ALL | E_STRICT. The documentation there is very thorough, and you may find a different setting that's better suited to your needs. Warning: as the PHP documentation states, this setting is only for development sites, not for production sites.

Looking for support? Visit the forums, or join #drupal-support in IRC.


kennywyland’s picture

I just pushed my first drupal site to production. I went into the admin/config/development/logging page to hide the warnings/errors on the production site, but no matter how many times I changed the value to None and hit submit, it would always tell me the changes were Saved but the value was back to All Messages. It was because these lines of code were still in my settings and were overriding the value I set through the form.

I know it's mentioned in the last sentence of the article, but following these instructions on my first day as a newbie and then months later finally pushing to production... I had completely forgotten.

Dustin LeBlanc’s picture

An even better solution is to keep a seperate include file such as settings.local.php in your site directory. Just don't push this file to the server; it can hold all of your local development overrides. I believe D8 core now has an example file included and a call to it commented out at the end of the default settings.php

Joel MMCC’s picture

The reason is that the Input Filter used for these pages requires the “<?php … ?>” tags to demarcate a code segment that’s to be surrounded by a thin gray border on a light grayish background, with line endings respected (unlike with normal HTML), HTML tags and entities non-interpreted (since PHP and most other programming languages use “<” and “>” and “&” for other things), and with PHP syntax color-coded.

The only way to do it without those tags would be to use the “<code>…</code>” block instead, which does the other things but does not do the PHP syntax color-coding that would be so very helpful in such tutorials.

Proposed solution:

When doing a PHP code block and you do not want the user to copy the actual <?php … ?> tags, insert comments instructing the reader exactly where to begin and end copying, something like this:

// Do NOT copy the “<?php” above, nor these two comment lines!
// ↓START copying at the beginning of the NEXT BELOW↓! 
$conf['error_level'] = 2;
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
// STOP copying at the END of the LINE JUST ABOVE↑!
// Do NOT copy the “?›” tag below, nor these two comment lines!
giorgio79’s picture

How about an option to show errors in a block, so we can limit display to admins? #2743119: Option to display php error messages in a block so we can limit visibility per role