Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How does Environment work?
  • So in config.php and scattered around some other stuff is Environment, which I'm used to either setting in index.php or something else, but I can't figure out how I'm supposed to set it in Fuel. There was a topic on using Oil to do it, but it was mixed up with migrations. I don't want to run a migration, I just want Fuel to know which environment I'm in.
  • The environment is set in app/config/config.php. Typical examples are defined as constants in the Fuel class, and a fresh Fuel setup defaults to Fuel::development. Alternatively, you can set the environment variable FUEL_ENV, which will have precedence over the config file. You can set this in your webserver config, or in a .htaccess, so the enviroment is set automatically and you don't have to change code when you move an application to production. In Fuel, the environment is only used in the database configuration.
  • Thanks WanWizard, you always know the answer! I was planning on using the environment for other things like error messages, but was trying to figure out if it was like CodeIgniter and controlled by index.php or something else, but whacking it in the htaccess is genius.
  • For those who don't know how to achieve this: in your htaccess file add the following:
    SetEnv FUEL_ENV Fuel::PRODUCTION
    

    Available options are detailed in the app/config/config.php file.
  • I would argue that this should be in the Docs – do you think I should add it in or raise it?
  • Thanks Phil, was investigating it as you posted it!
  • Yeah your right it should be detailed in the docs really. Raise a change request or pull in the docs issues on Git.

Howdy, Stranger!

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

In this Discussion