CodeIgniter Enable Disable debug mode

Today, We want to share with you CodeIgniter Enable Disable debug mode.In this post we will show you codeigniter enable error reporting, hear for codeigniter enable profiler globally we will give you demo and example for implement.In this post, we will learn about Development Environments in CodeIgniter with an example.

CodeIgniter Enable Disable debug mode

There are the Following The simple About CodeIgniter Enable Disable debug mode Full Information With Example and source code.

As I will cover this Post with live Working example to develop Error reporting and debugging in codeigniter, so the Enable/Disable debug mode in CodeIgniter for this example is following below.

disable codeigniter debug mode

class MY_Log extends CI_Log
    protected $_levels  = array('ERROR' => '1', 'INFO' => '2',  'DEBUG' => '3', 'ALL' => '4');
 * codeigniter Constructor
    public function __construct()

Error reporting handling in Codeigniter

enable displaying php errors on CodeIgniter


display_errors = ture, E_ALL, false, E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE

define('ENVIRONMENT', 'development');

Database Errors

$db['default']['db_debug'] = FALSE; 

Database Errors : $config[‘log_threshold’]

  $config['log_threshold'] = 1;

CodeIgniter 2+:

define('ENVIRONMENT', 'development');

CodeIgniter 3+:

define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');

CodeIgniter sets up error reporting

if (defined('ENVIRONMENT')) {
    switch (ENVIRONMENT) {
        case 'development':

        case 'production':

            exit('The CodeIgniter application environment is not set correctly.');


$config['base_url'] = 'http://localhost/pakainfo';


$config['base_url'] = '';


$config['base_url'] = '';

CodeIgniter index.php file

define('ENVIRONMENT', 'production'); 


$local_servers = array('localhost');
$isLocal = in_array($_SERVER['SERVER_NAME'], $local_servers);

if ($isLocal) {
    $env = 'local';
} else {
    // CodeIgniter check development word in website url
    preg_match('#/development#', $_SERVER['REQUEST_URI'], $isDevelopment);

    $env = $isDevelopment ? 'development' : 'production';

CodeIgniter Set and Get $env variable

define('ENVIRONMENT', $env);

How to disable codeigniter debug mode?

To disable the Debug Mode in CodeIgniter, you can make changes to the config.php file located in the application/config directory.

Here are the steps to disable Debug Mode in CodeIgniter:

Open the config.php file in a text editor.
Find the following line of code:

$config['debug'] = 1;

Change the value of debug from 1 to 0.

$config['debug'] = 0;

Save the changes to the config.php file.

With these changes, Debug Mode in CodeIgniter will be disabled and error messages will not be displayed on the screen. It’s recommended to disable Debug Mode in a production environment as it may reveal sensitive information to the end-user.

Angular 6 CRUD Operations Application Tutorials

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about CodeIgniter Enable Disable debug mode.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment