CodeIgniter Forums
$_SERVER['CI_ENV'] -- where is and ENVIRONMENT this set? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: $_SERVER['CI_ENV'] -- where is and ENVIRONMENT this set? (/showthread.php?tid=62111)

Pages: 1 2


RE: $_SERVER['CI_ENV'] -- where is and ENVIRONMENT this set? - Narf - 03-14-2016

(03-14-2016, 07:21 AM)kilishan Wrote: One way that I've handled this in other situations where CI_ENV wasn't available, or the client wasn't tech-savvy enough to set it keep it set Smile was something like this in CI's index.php file:

Code:
$domain = ! empty($_SERVER['HTTP_HOST']) ? strtolower($_SERVER['HTTP_HOST']) : 'cli';

if (strpos($domain, '.dev') !== false || $domain == 'cli')
{
   define('ENVIRONMENT', 'development');
}
else {
   define('ENVIRONMENT', 'production');
}

Don't do this. It allows any user to force 'development' as the ENVIRONMENT value.


RE: $_SERVER['CI_ENV'] -- where is and ENVIRONMENT this set? - kilishan - 03-14-2016

(03-14-2016, 07:36 AM)Narf Wrote: Don't do this. It allows any user to force 'development' as the ENVIRONMENT value.

Damn, good point. Bad developer, no cookie.

And thanks for pointing that out.


RE: $_SERVER['CI_ENV'] -- where is and ENVIRONMENT this set? - webmachine - 04-19-2016

What does 'db_debug' => (ENVIRONMENT !== 'production') in database.php do? Does this set the ENVIRONMENT constant, so if I launch an application I could just change this to 'db_debug' => (ENVIRONMENT == 'production')?


RE: $_SERVER['CI_ENV'] -- where is and ENVIRONMENT this set? - kilishan - 04-19-2016

This does not set the environment. It sets the 'db_debug' value to the results of the check. The check itself will be TRUE if the the environment is anything other than 'production'. ENVIRONMENT itself is set in the index.php file.


RE: $_SERVER['CI_ENV'] -- where is and ENVIRONMENT this set? - webmachine - 04-19-2016

Sorry if this might be off-topic, but under what circumstances would I change this?


RE: $_SERVER['CI_ENV'] -- where is and ENVIRONMENT this set? - kilishan - 04-19-2016

Since that setting only determines whether the database error screen is shown or not, I would never want it to show in production. You might alter it not to show in staging servers, or the like, but that's about the only use I can think of for it.