Welcome Guest, Not a member yet? Register   Sign In
$_SERVER['CI_ENV'] -- where is and ENVIRONMENT this set?

(03-14-2016, 12:32 AM)allenlee Wrote: I really think
PHP Code:
is useless.

Why not just use
PHP Code:

Let's make thing simple.

To be fair, simple really depends on your workflow. To be able to set CI_ENV on a staging server and a production server in .htaccess (or equivalent), then simply have the code updated on pushes to master branch in git is super simple for that workflow. To require the deploy script to manually edit the index.php file to change the environment every time a push happens is potentially problematic.

For those that don't use it, it is effectively the same thing as define('ENVIRONMENT', 'development');

(06-12-2015, 06:49 AM)lexxtoronto Wrote: I followed some examples and I tried to set it in .htaccess with some ifs depending on the url e.g. if it's localhost then set Development etc, and then setting it like this in index.php:

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

But it only worked on my localhost and not on my server. So I just hard coded in the index.php:

define('ENVIRONMENT', 'production');

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:

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

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

Messages In This Thread
RE: $_SERVER['CI_ENV'] -- where is and ENVIRONMENT this set? - by kilishan - 03-14-2016, 07:21 AM

Theme © iAndrew 2016 - Forum software by © MyBB