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.

Also Read :  jQuery Hide DIV After 5 Seconds Dynamic

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()
    {
        parent::__construct();
    }
}

Error reporting handling in Codeigniter

enable displaying php errors on CodeIgniter

   error_reporting(E_ALL);

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':
            error_reporting(E_ALL);
            break;

        case 'production':
            error_reporting(0);
            break;

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

application/config/local/config.php:

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

application/config/development/config.php:

$config['base_url'] = 'https://pakainfo.com/development';

application/config/production/config.php:

$config['base_url'] = 'https://pakainfo.com';

CodeIgniter index.php file

define('ENVIRONMENT', 'production'); 

CodeIgniter ENVIRONMENT

$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);

Angular 6 CRUD Operations Application Tutorials

Read :

Also Read :  Insert,Update, Delete using Angular js in ASP.NET MVC

Summary

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 Pakainfo.com 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.