Welcome Guest, Not a member yet? Register   Sign In
How to add variables from a second custom env file to the default one

(This post was last modified: 06-14-2024, 04:13 AM by serialkiller.)

I would need to load an additional env file in addition to the default env file.

It is possible to load an env file with dedicated values and merge them with the default env file values, e.g. .env.myenv?

Latest version of Codeigniter 4.5.2

I think it's impossible.
 You can read the file .env.local.php in app/Common.php with require "../.env.local.php"
In the file .env.local.php use the setenv() or other functions.
I hope this helps.
Simple CI 4 project for beginners codeigniter-expenses ( topic )

In public/index.php, afetr
PHP Code:
$paths = new Config\Paths(); 

use CodeIgniter\Config\DotEnv;

PHP Code:
require_once $paths->systemDirectory '/Config/DotEnv.php';
DotEnv($paths->appDirectory '/../''.env.' $_SERVER['HTTP_HOST']))->load(); 

But I'm still not sure it's the best way

Theme © iAndrew 2016 - Forum software by © MyBB