Bug Report #912

Multiple Configuration Levels

Added by Sam de Freyssinet over 6 years ago. Updated over 5 years ago.

Status:ClosedStart date:
Priority:LowDue date:
Assignee:Sam de Freyssinet% Done:


Target version:2.4
Resolution:wontfix Points:


To easy development to server deployment I would suggest that creating tiers for certain configuration files.

This would mean that 'database.php' (for example) could have DB settings for 'development', 'testing', 'deployment' and a system setting would control which DB setting to use, based on the stage of development. Yes I know this is somewhat similar to a certain RoR, but please forgive that.

Other Kohana System config files I feel would benefit from this include config.php and upload.php. Plus any other platform specific configuration files that user may generate.

Currently we are using SVN:ignore on these files, but it would be nice if we could just change one property and all the correct settings were loaded for the current environment.


#1 Updated by Geert De Deckere over 6 years ago

What about defining an extra constant, such as IN_PRODUCTION, in index.php and then using ternaries in your configuration files:

$config['site_domain'] = IN_PRODUCTION ? 'mydomain.com/' : 'localhost/';

I know this is not exactly what you are asking for, but just wanted to make sure we all know how this can work currently.

#2 Updated by Sam de Freyssinet over 6 years ago

I like the sound of this, simple and effective. But my only niggle would be that it can only support two deployment stages. It would be nice to have three or more... we use three here at Mukuru btw

#3 Updated by Ted Wood - over 6 years ago

I agree with polarisdigital. I've used the domain running the site as a way of switching between configuration options. If there were officially supported in Kohana, it would be huge. The IN_PRODUCTION constant doesn't offer enough flexibility.

For example, I also have 3 basic sets of configuration:

1) an in-development version (site.local)
2) a testing version on the production server for the client to follow (test.site.com)
3) a live version that'll be replaced with testing version (www.site.com)

By checking the domain, I can toggle the correct settings off/on.

I'm not really proposing a solution, but rather sharing my own need for a creative solution. If/when I come up with a possible solution, I'll report back.

#4 Updated by spirit - over 6 years ago

Just a thought, isn't it possible to create different configuration groups in your database config file (dev, staging, prod) and instanciate the correct one regarding the domain being called.

#5 Updated by Sam de Freyssinet over 6 years ago

@spirit yes that is true. But I don't think you can tell ORM which Database instance to use so easily AFAIK.

It is easy to use those additional configurations with Database::instance( $db_config_name );

But there is too much emphasis on Database config going on. It's all server environment specific configurations I was talking about, database.php was just one example. It would be nice to have a system wide setting for which mode/zone/tier the application instance is in.

#6 Updated by Kiall Mac Innes almost 6 years ago

+1 on this ... I keep hearing this come up over and over ...

I've got something hacked together already for this - but something official would be much better.

#7 Updated by Josip Jelic almost 6 years ago

There will be many uses for this feature. ImageMagick (different paths), different MySQL database names/usernames, error reporting....

Now we must have separate versions of config files locally and online which can be hard to maintain.

Solution should be domain specific because IMO this is the only way to say for sure "where" the code is running.

#8 Updated by Jeremy Bush over 5 years ago

  • Status changed from New to Assigned
  • Assignee changed from Woody Gilk to Sam de Freyssinet
  • Priority changed from Normal to Low

#9 Updated by Ben Rogers over 5 years ago

  • Status changed from Assigned to Closed
  • Resolution set to wontfix

Also available in: Atom PDF