CodeIgniter User Guide Version 2.2.6 |
Table of Contents Page |
CodeIgniter Home › User Guide Home › Handling Multiple Environments |
Developers often desire different system behavior depending on whether an application is running in a development or production environment. For example, verbose error output is something that would be useful while developing an application, but it may also pose a security issue when "live".
By default, CodeIgniter comes with the environment constant set to 'development'. At the top of index.php, you will see:
define('ENVIRONMENT', 'development');
In addition to affecting some basic framework behavior (see the next section), you may use this constant in your own development to differentiate between which environment you are running in.
There are some places in the CodeIgniter system where the ENVIRONMENT constant is used. This section describes how default framework behavior is affected.
Setting the ENVIRONMENT constant to a value of 'development' will cause all PHP errors to be rendered to the browser when they occur. Conversely, setting the constant to 'production' will disable all error output. Disabling error reporting in production is a good security practice.
Optionally, you can have CodeIgniter load environment-specific configuration files. This may be useful for managing things like differing API keys across multiple environments. This is described in more detail in the environment section of the Config Class documentation.
Previous Topic: Managing Applications · Top of Page · User Guide Home · Next Topic: Alternative PHP Syntax
CodeIgniter · Copyright © 2006 - 2014 · EllisLab, Inc. · Copyright © 2014 - 2015 · British Columbia Institute of Technology