Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Dynamic Environments
  • Hi All, I'm trying to figure out a good way to have a config file that changes the Fuel Environment depending on the server the files are located on. I've been using a method I found in some of Phil's code: https://github.com/philsturgeon/amiafucktard.com/blob/master/fuel/app/config/config.php#L32
    strpos($_SERVER, 'local.') !== FALSE ? Fuel::DEVELOPMENT : Fuel::PRODUCTION

    It's been working great for what I need until I started to play with Oil today. I'm now getting the error:
    $ php oil -v
    PHP Notice: Undefined index: SERVER_NAME in C:\xampp\htdocs\fuel\fuel\app\
    config\config.php on line 32 Notice: Undefined index: SERVER_NAME in C:\xampp\htdocs\fuel\fuel\app\confi
    g\config.php on line 32
    Fuel: 1.0.0-dev

    Any ideas on how to better code this to have a config file that is dynamic based on its environment and doesn't break oil?
  • Try using this:
    (isset($_SERVER['SERVER_NAME']) && strpos($_SERVER['SERVER_NAME'], 'local.') !== FALSE)
     ? Fuel::DEVELOPMENT
     : Fuel::PRODUCTION;
    
  • That works great! Thanks :)
  • No problemo, glad to have helped :)

Howdy, Stranger!

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

In this Discussion