![]() |
app.baseurl or public $baseURL - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: app.baseurl or public $baseURL (/showthread.php?tid=82640) |
app.baseurl or public $baseURL - gfgrisales - 08-03-2022 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/' PHP Code: public $baseURL = 'http://myurl.any/'; 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. ![]() 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? ![]() RE: app.baseurl or public $baseURL - kilishan - 08-03-2022 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. RE: app.baseurl or public $baseURL - ozornick - 08-03-2022 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() RE: app.baseurl or public $baseURL - gfgrisales - 08-04-2022 (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! ![]() |