Welcome Guest, Not a member yet? Register   Sign In
Reload .env file in runtime
#3
Photo 

(08-24-2024, 07:45 PM)kenjis Wrote: Try
PHP Code:
(new DotEnv($paths->appDirectory '/../'))->load(); 
hi kenjis..i have try that..but not work..
DotEnv successfuly load the new .env, but the configuration DB still use default value,not use value from the new .env

step
1. first i dont have .env,
So i Running in first time the CLI ,and i Check the config DB in this case CI automatic load default config DB.

2. i run my command to automaticly generate .env , load that with DotEnv ,
and check again with config:check Database, but the value config DB not change.

Code:
        //step  Checking first time config db
        CLI::wait(2);
        CLI::write('Checking first time config db`...', 'black', 'green');
        command('config:check Database');

        //step 2 Generate env
        CLI::wait(2);
        CLI::write('Generate env `key:generate`...', 'black', 'green');
        $this->call('key:generate');

        //passing value in .env
        CLI::wait(2);
        CLI::write('Running `passing value env`...', 'black', 'green');
        $this->setEnv($domain, $dbHost, $dbName, $dbUser, $dbPassword, $driver, $port);
        CLI::showProgress($currStep++, $totalSteps);

        //step 3 clear cache
        CLI::wait(2);
        CLI::write('Running `Clear Cache`...', 'black', 'green');
        command('cache:clear');

        //step 4 load New ENV
        CLI::wait(2);
        CLI::write('Load `Env`...', 'black', 'green');
        $paths = new Paths();
        (new DotEnv($paths->appDirectory . '/../'))->load();


        //step 5 Checking if config DB has change with new ENV
        CLI::wait(2);
        CLI::write('Checking if config DB has change with new ENV', 'black', 'green');
        command('config:check Database');
        die; //stop just testing


[Image: ad.jpg]

[Image: ad.jpg]

the .env has generate n load.but the config not change
[Image: ad.jpg]
Reply


Messages In This Thread
Reload .env file in runtime - by dhiya as - 08-24-2024, 12:19 AM
RE: Reload .env file in runtime - by kenjis - 08-24-2024, 07:45 PM
RE: Reload .env file in runtime - by dhiya as - 08-25-2024, 12:07 AM
RE: Reload .env file in runtime - by kenjis - 08-25-2024, 02:17 AM
RE: Reload .env file in runtime - by kenjis - 08-25-2024, 02:21 AM
RE: Reload .env file in runtime - by dhiya as - 08-25-2024, 03:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB