Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 1 | ############################## |
| 2 | Handling Multiple Environments |
| 3 | ############################## |
| 4 | |
| 5 | Developers often desire different system behavior depending on whether |
| 6 | an application is running in a development or production environment. |
| 7 | For example, verbose error output is something that would be useful |
| 8 | while developing an application, but it may also pose a security issue |
| 9 | when "live". |
| 10 | |
| 11 | The ENVIRONMENT Constant |
| 12 | ======================== |
| 13 | |
| 14 | By default, CodeIgniter comes with the environment constant set to |
| 15 | 'development'. At the top of index.php, you will see:: |
| 16 | |
| 17 | define('ENVIRONMENT', 'development'); |
| 18 | |
| 19 | In addition to affecting some basic framework behavior (see the next |
| 20 | section), you may use this constant in your own development to |
| 21 | differentiate between which environment you are running in. |
| 22 | |
| 23 | Effects On Default Framework Behavior |
| 24 | ===================================== |
| 25 | |
| 26 | There are some places in the CodeIgniter system where the ENVIRONMENT |
| 27 | constant is used. This section describes how default framework behavior |
| 28 | is affected. |
| 29 | |
| 30 | Error Reporting |
| 31 | --------------- |
| 32 | |
| 33 | Setting the ENVIRONMENT constant to a value of 'development' will cause |
| 34 | all PHP errors to be rendered to the browser when they occur. |
| 35 | Conversely, setting the constant to 'production' will disable all error |
| 36 | output. Disabling error reporting in production is a :doc:`good security |
| 37 | practice <security>`. |
| 38 | |
| 39 | Configuration Files |
| 40 | ------------------- |
| 41 | |
| 42 | Optionally, you can have CodeIgniter load environment-specific |
| 43 | configuration files. This may be useful for managing things like |
| 44 | differing API keys across multiple environments. This is described in |
| 45 | more detail in the environment section of the `Config |
| 46 | Class <../libraries/config.html#environments>`_ documentation. |