-1

I am trying to install a Codeigniter application in pure NGINX + PHP-FPM environment but it was previously developed in apache .

After adding all the proper rules to Nginx in order to work with Codeigniter I am being faced with this error related to my $_ENV variable .

Undefined variable: _ENV in /home/nginx/domains/mydomain.com/system/Config/BaseConfig.php ?

Here is the code calling the $_ENV variable :

case array_key_exists("{$shortPrefix}.{$property}", $_ENV):
                            return $_ENV["{$shortPrefix}.{$property}"];
                            break;
                    case array_key_exists("{$shortPrefix}.{$property}", $_SERVER):
                            return $_SERVER["{$shortPrefix}.{$property}"];

Worth mentioning I am trying to call a task by running php spark task:run tasks when the error takes place in CLI .

Things I have tried to do so far :

1) I have added a _ENV variable to my PHP-FPM this way :

env[_ENV] = production

2) I exported ENV variable in CLI :

export _ENV=production

3) I have added the following line in Nginx Config :

location / {

  fastcgi_param CI_ENV  production;

}

Nothing seems to work and my $_ENV or $SERVER variables always seem empty and I get the same error when I try to run my task .

Anything else I can make to debug this and setup my $_ENV variable to run properly with my app ?

1 Answers1

0

Found the solution !

Changing the default of this variable in PHP.INI to off did the trick !

auto_globals_jit = Off
  • [`auto_globals_jit`](https://www.php.net/manual/en/ini.core.php#ini.auto-globals-jit) should have no effect for your case. The warning in the docs does mention basically that if it's `on` *and* you're using variable variable to refer to `$_ENV`, then it won't be initialized. But you're clearly using `$_ENV` reference in your code. You likely had it "fixed" by `export _ENV=production` alone. – Danila Vershinin Sep 27 '20 at 21:41