Welcome Guest, Not a member yet? Register   Sign In
app.baseurl or public $baseURL
#1

(This post was last modified: 08-03-2022, 06:32 AM by gfgrisales.)

I've been looking around but I still can't find a clear concept about the diferrences of these two:

PHP Code:
app_baseURL 'http://myurl.any/'  
declared on the /.env file and

PHP Code:
public $baseURL 'http://myurl.any/'
 declared on the /app/config/App.php file

As far as my understanding goes about CodeIgniter the one declared on the .env file has development purposes only and the one in the App.php is for production... Or that's what I thougth.  Undecided

Running some tests today I found myself with an App crash after I removed/comment the public $baseURL from the App.php file even while in the .env file the CodeIgniter environment has been set as development.
PHP Code:
CI_ENVIRONMENT development 

What's the real difference and case of use for each one of them? Huh
Machines obbey the software instructions, software instructions obbeys the logic of the developer.
Therefore is not the systems fault if the developer's logic is fudged up!  ¯\_(ツ)_/¯
Reply
#2

The value in the .env file will override the value in the config file. It is designed to allow you to have a .env file in staging and another in production, both with the appropriate credentials for that environment. Then the credentials don't get saved in any repositories and kept safe on the respective servers.
Reply
#3

I would advise you to specify Config\App.baseUrl in the .env file. Then the variable will be available directly via config("App.baseUrl") , not via getenv()
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#4
Thumbs Up 

(08-03-2022, 06:35 AM)kilishan Wrote: The value in the .env file will override the value in the config file. It is designed to allow you to have a .env file in staging and another in production, both with the appropriate credentials for that environment. Then the credentials don't get saved in any repositories and kept safe on the respective servers.

Fantastic answer, made it all clear now.
Thank you so much Kilishan!  Cool
Machines obbey the software instructions, software instructions obbeys the logic of the developer.
Therefore is not the systems fault if the developer's logic is fudged up!  ¯\_(ツ)_/¯
Reply




Theme © iAndrew 2016 - Forum software by © MyBB