Welcome Guest, Not a member yet? Register   Sign In
Cron job doesn't load CI_ENV config in .htaccess with CodeIgniter 3.1.9
#1

I'm using a Cron job with CodeIgniter. Since this is the server that run the script, the config in the .htaccess is not loaded. The problem is :

    # CI set environment 
    SetEnv CI_ENV production

As the .htaccess is not loaded, this is the default *development* environment that is loaded. The direct consequence is that access to DB failed. 

How should I properly solved this problem ?
Reply
#2

(11-10-2018, 12:52 AM)imabot Wrote: I'm using a Cron job with CodeIgniter. Since this is the server that run the script, the config in the .htaccess is not loaded. The problem is :

    # CI set environment 
    SetEnv CI_ENV production

As the .htaccess is not loaded, this is the default *development* environment that is loaded. The direct consequence is that access to DB failed. 

How should I properly solved this problem ?

What I have done is edit index.php changing
PHP Code:
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development); 
to
PHP Code:
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production'); 

Because "production" seems like a safer choice to make when you cannot safely determine exactly what the environment is.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB