Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Oil - setting the env variable
Colt
January 2019
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
January 2019
Accepted Answer
What OS?
Colt
January 2019
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
Harro
January 2019
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
Colt
January 2019
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
Colt
January 2019
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");
}
Harro
January 2019
Ah, yeah, if you remove the original code, it no longer works.
;-)
Glad to hear you've got it sorted.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,086
General
↳ General
3,362
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Colt
January 2019
Harro
January 2019