Codeigniter has its ‘ENVIRONMENT’ setting such that when in a production environment, by changing the setting to ‘production’, all of the production configuration files are included.
A large amount of my website utilizes javascript. As such I want to have some config such as the below which changes dependent on whether i’m in a local or production environment.
<base href="http://localhost/site/" />
<script type="text/javascript">
var base_url = 'http://localhost/site/';
</script>
Does anyone know how i can make codeigniter include config/production/custom-config.php
And if I could, surely that wouldn’t be a suitable place for such configuration?
Many Thanks
CodeIgniter includes as
base_urlconfiguration variable located inapplication/config/config.php. You could do something like this:Does anyone know how i can make codeigniter include config/production/custom-config.php And if I could, surely that wouldn’t be a suitable place for such configuration?
You can easily create custom config files. Create a file in the
application/config/folder (or the appropriate environment folder). For example:*application/config/production/custom_config.php:*
Then you can load your new configuration file using:
And access your configuration variables using:
Finally, take a look at the documentation on the Config Class.