Skip to content

Allow selecting the environment via CI_ENV - #3473

Merged
magicbug merged 1 commit into
magicbug:devfrom
mezinster:upstream-ci-env-lookup
Oct 1, 2026
Merged

magicbug merged 1 commit into
magicbug:devfrom
mezinster:upstream-ci-env-lookup

Conversation

@mezinster

@mezinster mezinster commented Oct 1, 2026 •

Copy link
Copy Markdown

index.php hardcodes define('ENVIRONMENT', 'development');, and CodeIgniter's standard CI_ENV lookup sits commented out above it. To run in production today, admins have to edit index.php, which then conflicts on every git pull.

This switches to the standard lookup:

define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');

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:

  • Apache: SetEnv CI_ENV production (vhost or .htaccess)
  • nginx + PHP-FPM: fastcgi_param CI_ENV production;
  • CLI (php index.php migrate): CI_ENV=production php index.php ...

Testing

  • php -l index.php on PHP 7.4.33 and 8.2.34
  • Apache + PHP 8.2 deployment with SetEnv CI_ENV production: pages render without PHP notices and without the "Developer mode" badge
  • Without CI_ENV set, the expression falls back to development, the same value as the current hardcoded line

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ENV from $_SERVER.
  • Preserves development as 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.

@magicbug
magicbug merged commit db6d0dc into magicbug:dev Oct 1, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants