Codigniter 4.6.1 not loading config files based on environment |
(06-03-2025, 10:59 PM)chenzen Wrote: The ci4 I downloaded from the website, I did not modify anything, just renamed the env to .env, and it did not load, that was the error I was reporting. I wasn't able to reproduce this behavior. (06-03-2025, 10:59 PM)chenzen Wrote: I believe solutions should stay simple and be very flexible, the env file being loaded in the index.php was very good and makes it possible to use it in "distributed" environments, where the same "app" and "system" is used to run multiple databases/setups. I don't think this is much more complicated. Yes, you have to create an additional file, but you gain a space to implement the whole logic responsible for choosing the env file properly. It may not be ideal for your use case, but we have to see the bigger picture here, and for me, this is a better solution, as it unlocks a lot of features. (06-03-2025, 10:59 PM)chenzen Wrote: The second issue was the ability of the frame work to load config files based on the "ENVIRONMENT", that ability is also helpful. If I am deploying the same code base across multiple servers for different clients, all I have to do is to ensure that I have their .env file and their config file, and working on it becomes easy. I will be glad if that can be considered. You can implement this with the use of the custom Boot class. So I don't see a problem (06-03-2025, 10:59 PM)chenzen Wrote: The ability to serve different configurations should be a serious consideration, the config helps do that easily, very helpful for the developer. As @grimpirate mentioned, you may need a different approach, but if not... this will be quite a unique use case. So, again, you can use a custom Boot class. Also, we always welcome code contributions, so feel free to send a PR with the enhancement to the 4.7 branch if you want. (06-03-2025, 10:59 PM)chenzen Wrote: But how do we come up with ci4 updates ? what determines what is taken away and what is introduced? In this case, maintainers decided that moving code to the Boot class would make the code more readable and easier to maintain, as the Boot class is used in a couple of places, like: index.php, spark, and Test/bootstrap.php.
michalsn.dev - mostly about CodeIgniter
|
Welcome Guest, Not a member yet? Register Sign In |