Welcome Guest, Not a member yet? Register   Sign In
Allow more environments
#1

Currently if you set CI_ENV to anything other than "development", "testing" or "production" you get a 503 error.
Our project has two testing environments. One at our development office, one on the production server, running under a different subdomain.

Local development, dev-testing (in docker), production-server testing and real "production" all have differences in either the name or IP address of the database. Currently to work around this we stray from the official versions, because of custom workarounds to this problem.

There should really be no issue as to set the environment to any string we want and that environment's configuration files to be loaded from the usual "application/config/myenv".
Reply
#2

You have described 3 environments if I am not mistaken.

So why can't you do this?

Development office                 => CI_ENV = "development"
Development production server => CI_ENV = "testing"
Production server                   => CI_ENV = "production"
Reply
#3

(This post was last modified: 08-02-2017, 10:06 AM by katz.)

(08-02-2017, 09:12 AM)Martin7483 Wrote: You have described 3 environments if I am not mistaken.

So why can't you do this?

Development office                 => CI_ENV = "development"
Development production server => CI_ENV = "testing"
Production server                   => CI_ENV = "production"

Four:
Code:
Local development                      => CI_ENV = "development" // db ip: localhost, dbname: name1
Office testing                         => CI_ENV = "docker" // db ip: externalhost, dbname: name1
Production server testing subdomain    => CI_ENV = "testing" // db ip: localhost, dbname: name2
Production server real site            => CI_ENV = "production" // db ip: localhost, dbname: name1

All it would take is to remove the default case to a 503 error in the ENVIRONMENT switch, but I know changes have to be justified, so I didn't go straight for a pull request.
Reply
#4

We would still need to throw some form of error, so the default needs to stay. However, adding a config setting of some form could be a good solution.
Reply
#5

You can add additional environments yourself in the top half of the index.php file (the half you can customize):

Code:
switch (\ENVIRONMENT)
{
    case 'cli':
    case 'local':
    case 'development':
        error_reporting(-1);
        ini_set('display_errors', 1);
    break;
    case 'production':
        ini_set('display_errors', 0);
        if (version_compare(PHP_VERSION, '5.3', '>='))
        {
            error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
        }
        else
        {
            error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
        }
    break;
    default:
        header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
        echo 'The application environment is not set correctly.';
        exit(1); // EXIT_ERROR
}
Reply
#6

Actually, looking at the code, there is not any limits placed on what environments are allowed. I think the issue is that the environment variable used was changed a little while back. It's not CI_ENV any longer, it's CI_ENVIRONMENT.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB