CodeIgniter Forums
The version 4.5.0 cause problems with loading dotEnv - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: The version 4.5.0 cause problems with loading dotEnv (/showthread.php?tid=91007)



The version 4.5.0 cause problems with loading dotEnv - equinton - 06-04-2024

Hello,
I develop applications whose code is shared by multiple instances on the same platform (multiple URLs, with separate parameters for each). To do that, I've modified the index.php
code with:
Code:
if (is_file($file = $_SERVER["envPath"] . DIRECTORY_SEPARATOR . ".env") && is_readable($file)) {
    (new CodeIgniter\Config\DotEnv($_SERVER["envPath"],".env"))->load();
The envPath variable is assigned in apache2 vhost, each instance has its own vhost file.
But in the last version (4.5.0), this code as migrated to the core of CodeIgniter. If I can change the Boot.php file to insert it, a
Code:
composer upgrade
will overwrite it.
Have you a solution to avoid this overwrite?
Thanks,
Eric Q.


RE: The version 4.5.0 cause problems with loading dotEnv - codeus - 06-04-2024

Could you possible put the index.php code in a BaseController or use a Filter?
index.php changes often - in many CI version updates.
Mike


RE: The version 4.5.0 cause problems with loading dotEnv - kenjis - 06-04-2024

Extend "CodeIgniter\Boot", and use your Boot in "index.php".