Repository navigation
Allow selecting the environment via CI_ENV - #3473
Merged
Merged
Conversation
Use CodeIgniter's standard CI_ENV lookup instead of hardcoding ENVIRONMENT. The default stays 'development', so existing installs behave exactly as before; deployments can opt into production with `SetEnv CI_ENV production` (Apache) or `fastcgi_param CI_ENV production` (nginx) instead of editing index.php, which conflicts on every update.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused change preserves existing behavior while enabling standard environment configuration.
Review effort: Balanced
Findings: None
What changed in this PR
Enables deployment-specific CodeIgniter environments without editing tracked files.
Changes:
- Reads
CI_ENVfrom$_SERVER. - Preserves
developmentas the default.
| File | Description |
|---|---|
index.php |
Configures ENVIRONMENT from CI_ENV with the existing fallback. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
index.phphardcodesdefine('ENVIRONMENT', 'development');, and CodeIgniter's standardCI_ENVlookup sits commented out above it. To run in production today, admins have to editindex.php, which then conflicts on everygit pull.This switches to the standard lookup:
The default is still
development, so unlike #2733 this doesn't change behaviour for any existing install and needs no action from users. Admins who want production mode can opt in without touching tracked files:SetEnv CI_ENV production(vhost or.htaccess)fastcgi_param CI_ENV production;php index.php migrate):CI_ENV=production php index.php ...Testing
php -l index.phpon PHP 7.4.33 and 8.2.34SetEnv CI_ENV production: pages render without PHP notices and without the "Developer mode" badgeCI_ENVset, the expression falls back todevelopment, the same value as the current hardcoded line