Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Oil - setting the env variable
  • Hi,

    I can't seem to get the oil package to run under a different environment, it seems to force to development 

    env FUEL_ENV=test php oil -v
    Fuel: 1.8 running in "development" mode

    Any help would be very much appreciated

    Trying to use oil tasks - which needs to look at DB configs etc for the specific env
  • Harro VertonHarro Verton
    Accepted Answer
    What OS?
  • Red Hat 7.6 - 

    I can see the env var if I type "env"

    But when I run oil, it still defaults to dev


    $ env
    FUEL_ENV=test

    $ php oil -v
    Fuel: 1.8 running in "development" mode


    It seems as though I need to use "export FUEL_ENV=test" on this OS, which does show the env variable when I run env

    But oil doesn't seem to be using it when I run the oil -v command


  • I'm on Fedora and Centos 7.5, and I can't reproduce your issue:

    /data/www/fuelphp/1.8/master  (1.8/master)
    [wanwizard@catwoman] $ env FUEL_ENV=test php oil -v
    Fuel: 1.8.1 running in "test" mode

    You can also use it without "env":

    /data/www/fuelphp/1.8/master  (1.8/master)
    [wanwizard@catwoman] $ FUEL_ENV=test php oil -v
    Fuel: 1.8.1 running in "test" mode

  • Thanks for the help Harro,

    I still can't seem to get it to listen to that env var

    Do any of the other configs override this with the Oil package?

    I generally set the environment in the bootstrap but believe this won't take effect outside of the web scope?

    if ( isset($_SERVER['APPLICATION_ENV']) ){
    switch($_SERVER['APPLICATION_ENV']){
    case "DEV":
    Fuel::$env = "development";
    break;
    case "TEST":
    Fuel::$env = "test";
    break;
    case "PROD":
    Fuel::$env = "production";
    break;
    }
    }


    I'll take a look at the oil package too see if I can figure out where it's reading the the environment
  • Ok, all sorted!
    The bootstrap wasn't referencing the FUEL_ENV var at all

    Altered to:

    if ( isset($_SERVER['APPLICATION_ENV']) ){
    switch($_SERVER['APPLICATION_ENV']){
    case "DEV":
    Fuel::$env = "development";
    break;
    case "TEST":
    Fuel::$env = "test";
    break;
    case "PROD":
    Fuel::$env = "production";
    break;
    }
    }else{
        Fuel::$env = (isset($_SERVER['FUEL_ENV']) ? $_SERVER['FUEL_ENV'] : "development");
    }

  • Ah, yeah, if you remove the original code, it no longer works. ;-)

    Glad to hear you've got it sorted.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion