What is CodeIgniter 4 environment-specific configuration?

Answer

CI4 supports environment-specific configuration through the .env file and environment-based overrides. Set the environment: CI_ENVIRONMENT = production in .env. This changes: debug toolbar visibility, error display verbosity, and can trigger environment-specific code paths: if (ENVIRONMENT === "production") { ... }. Config overrides via .env: any config class property can be overridden using the dot notation in .env: app.baseURL = https://mysite.com overrides Config\App::$baseURL. Database-specific: database.default.hostname = prod-db.example.com. This approach keeps environment-specific values out of PHP files and version control. CI4 also supports multiple .env files in theory, though it processes only one. Use separate .env files per server (.env.production, .env.staging) and symlink the appropriate one, or use server environment variables directly.