Added ability to override configurable settings from index.php #1524

Closed
wants to merge 1 commit into
from

Projects

None yet

4 participants

@webspy

If CodeIgniter's index.php is added under version control then all configurable settings in this file will also be tracked (even if some are machine specific). Having the ability to set or override configurable settings in a separate (unversioned and machine specific) file would make it easier to keep CodeIgniter's files under version control.

When upgrading index.php to a newer version one would not need to worry about changes to that file. The separate configuration file might also allow for logic for switching between different environments, applications or CodeIgniter installations.

For backwards compatibility this configuration file is optional.

@philsturgeon philsturgeon commented on the diff Jun 24, 2012
index.php
+ * APPLICATION ENVIRONMENT
+ *---------------------------------------------------------------
+ *
+ * You can load different configurations depending on your
+ * current environment. Setting the environment also influences
+ * things like logging and error reporting.
+ *
+ * This can be set to anything, but default usage is:
+ *
+ * development
+ * testing
+ * production
+ *
+ * NOTE: If you change these, also change the error_reporting variable below
+ */
+ $environment = isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development';
@philsturgeon
philsturgeon Jun 24, 2012

Well surely how the env detection is worked out and how it is handled (below) is as much config as anything else?

@webspy
webspy Jun 24, 2012

Sorry, I don't understand what you mean, could you please give more details ?

@philsturgeon

Sorry but I do not see the point of this. People try to avoid having a bootstrap that will even change, but the $_SERVER['CI_ENV'] var is configuration in itself. If somebody wants to detect the environment based on IP, hostname, etc then they will have to "configure" the code that detects the environment.

This just adds another file load to the page, and offers nothing. You have already detected the environment by the time you are loading the config file, so you fail to get any advantages of environment based configuration from it.

@webspy

The $_SERVER['CI_ENV'] detection was already there when I made the changes, I just converted from a constant to a variable.

What I was aiming for is the ability to have different application/system folders for different machines. On my local machine CodeIgniter might be installed in a shared location and the application folder in a development folder, while on a live server they might both be one level above root. If I want to add index.php under version control then I would be tracking settings (locations) specific to my local machine. With config.php I could have these settings in an unversioned file specific to each machine.

@philsturgeon

That use-case sounds a little different from the first, so thank you for explaining again.

When I need to set multiple applications using the same CI install and I have virtual hosts I do this:

SetEnv CI_APPPATH /home/to/some/place

Then you can point your application to wherever you like, or just hardcode the system and keep the apppath relevant. I'm not sure CI needs to change to accommodate this.

@webspy

I see your point, feel free to suggest changes or close this pull request if it does not make sense.

@philsturgeon

Thanks webspy, for taking the time to make it and for understanding my views against it.

+1 for closing

@narfbg @alexbilbie @ericbarnes

@webspy

Could you also review my other pull request (#1502) ? As with this pull request, my other pull request does not seem to add much but only simplify some things.

@alexbilbie

I do what @philsturgeon does and set most things in environment variables which gives the most flexibility on different machines. Therefore I agree with him on this.

@narfbg

Sorry @webspy, but I also agree with Phil and Alex - there are better ways to handle such installations.

@narfbg narfbg closed this Jun 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment