Multiple App with .env |
Hello everyone
I am looking to use .env environment files with an instance composed of several applications. For example, I want to have several applications on the same CodeIgniter instance but with different configurations (Example: baseUrl, database, etc.) How would you proceed? My structure on CI v4.5.0: app1 Config Controllers Database .. app2 Config Controllers Database .. app3 Config Controllers Database .. Thanking you in advance. Pierre
Define your own Environment Variables, and set the value to corresponding app's config.
E.g., In .env file: Code: BASE_URL1=https://app1.example.com/ In Config\App's constructor: PHP Code: $this->baseURL = env('BASE_URL1');
Hello and thank you for your answer
In fact, the idea was not to touch the files contained in the Config folder, because they are often updated. In previous versions, it was possible to choose a .env file in the public/index.php file. Now, apparently, this is no longer possible. (04-29-2024, 10:47 PM)piieerre Wrote: In previous versions, it was possible to choose a .env file in the public/index.php file. If you want to do like that, 1. extend the Boot class https://github.com/codeigniter4/CodeIgni...m/Boot.php 2. edit index.php to run your Boot class. https://github.com/codeigniter4/CodeIgni...hp#L53-L56
Thank you for your reply
Can you tell me how to proceed? How to extend the Boot class and where to place this file? Thanks in advance
app/Boot.php:
PHP Code: <?php Code: --- a/public/index.php
Thanks for your response
But I have an error : PHP Fatal error: Uncaught Error: Class "CodeIgniter\\Boot" not found in /var/www/vhosts/domain.com/app.domain.com/app/Boot.php:16
I recommend you learn how PHP works if you use CodeIgniter.
You need to load the class before using it. |
Welcome Guest, Not a member yet? Register Sign In |