Welcome Guest, Not a member yet? Register   Sign In
CI_DEBUG environment override
#1

Is it possible to override the CI_DEBUG constant in app/Config/Boot/development.php?

I would like to override this in .env without editing the development.php file so different environment can turn this on/off without committing the CI_DEBUG file change.

I have tried the following (below) with no success:


Code:
CI_DEBUG = false
development.CI_DEBUG = false
boot.development.CI_DEBUG = false
CI_DEBUG = 0
development.CI_DEBUG = 0
boot.development.CI_DEBUG = 0

If this is not possible by default, any suggestions on how to implement a solution into development.php to make it read the .env variables?

Thank you!
Reply
#2

My temporary solution has been to modify app/Config/Boot/development.php:

PHP Code:
defined('CI_DEBUG') || define('CI_DEBUG'getenv('CI_DEBUG') === 'false' false true); 

This seems to be the only workaround I have found, has anyone else dealt with this issue before?
Reply
#3

Try:
Code:
--- a/app/Config/Boot/development.php
+++ b/app/Config/Boot/development.php
@@ -29,4 +29,4 @@ defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
  | the system. This will control whether Kint is loaded, and a few other
  | items. It can always be used within your own application too.
  */
-defined('CI_DEBUG') || define('CI_DEBUG', true);
+defined('CI_DEBUG') || define('CI_DEBUG', $_ENV['CI_DEBUG']);
Reply
#4

I don't understand why you need to change the value for development.php. Since you're saying you want to turn it off in other environments, why not set "CI_ENVIRONMENT" to, for example, production so that you will use your production.php's value for CI_DEBUG which is false.
Reply
#5

Because I still want to debug errors but I just want Kint disabled.
In production, you only get a "Whoops" message on server errors. Where in development, you get more debug information shown on screen.
Reply
#6

(This post was last modified: 10-28-2022, 05:15 PM by kenjis.)

Kint is disabled in production environment by default.
It seems all you need to do is to set CI_ENVIRONMENT.
Reply
#7

But this is not a production environment. I am still developing, and want debugging information, just without Kint.
For example...

An error with CI_ENVIRONMENT set to development shows:
[Image: Vi9nKE+]

The same error with CI_ENVIRONMENT set to productions shows:
[Image: QEhvzC+]
Reply




Theme © iAndrew 2016 - Forum software by © MyBB