Bug Report #912
Multiple Configuration Levels
|Assignee:||Sam de Freyssinet||% Done:|
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 almost 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.
#3 Updated by Ted Wood - almost 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.
#5 Updated by Sam de Freyssinet almost 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.
#7 Updated by Josip Jelic over 5 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.