How to debug Codeigniter 4

Viewed 8329

whatever error occurs in Codeigniter 4 Its always showing default message Error message default from codeigniter 4

How to get exact error message in Codeigniter 4

7 Answers

Rename the env file as .env, then removed # from CI_ENVIRONMENT and modified

CI_ENVIRONMENT = production 

into

CI_ENVIRONMENT = development

Add this code to the index.php file at the top. Final Solution

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

Follow the following guidlines from docs

Copy or rename the env file to .env. Open it up.

Uncomment the line with CI_ENVIRONMENT on it, and change production to development

CI_ENVIRONMENT = development

and

Set the base url properly if you are not using PHP's built-in server

app/config/App.php

public $baseURL = 'http://localhost/path_to_CI/public';

Don't forget to rename :

env

to

.env

And uncomment #CI_ENVIRONMENT = development to CI_ENVIRONMENT = development

go to .env file in base file uncomment #CI_ENVIRONMENT = development to CI_ENVIRONMENT = development

There are something you need to Debug

  1. Rename the env file to .env

After Rename open the .env file. it looks like this.

enter image description here

Change this line

# CI_ENVIRONMENT = production

to

CI_ENVIRONMENT = development

After that try to create an error, then you will see error page like below.

enter image description here

Go to your directory project and open .env file
Change this

CI_ENVIRONMENT = production

To this

CI_ENVIRONMENT = development
Related