What's the difference between the .env file and App.php? - 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: What's the difference between the .env file and App.php? (/showthread.php?tid=77542) |
What's the difference between the .env file and App.php? - philio - 09-13-2020 So I'm trying to learn CI 4 and I have a question. In the .env file there are these settings: Code: # app.CSRFProtection = false And in Config/App.php there are these: Code: public $CSRFTokenName = 'csrf_test_name'; So what's the difference here? Where am I supposed to do my settings? Although I'm pretty sure it's working as it is without uncommenting the settings in the .env file. But why do they exist there? RE: What's the difference between the .env file and App.php? - jreklund - 09-13-2020 So that you can have three servers with different .env files, and you don't need to touch your Config/App.php to change local settings. RE: What's the difference between the .env file and App.php? - John_Betong - 09-13-2020 I'm going to rename my Config.php next time I'm on the desktop and see if .env alone is adequate because Config.php works without a .env file Edit: I will also try different values in the two files and see which has priority... RE: What's the difference between the .env file and App.php? - nc03061981 - 09-13-2020 (09-13-2020, 11:09 AM)jreklund Wrote: So that you can have three servers with different .env files, and you don't need to touch your Config/App.php to change local settings. Thanks for clearly RE: What's the difference between the .env file and App.php? - philio - 09-14-2020 What will happen if I have different settings in both the App.php file and the .env file. Which one will override the other? RE: What's the difference between the .env file and App.php? - jreklund - 09-14-2020 .env will override your configuration settings. RE: What's the difference between the .env file and App.php? - tgix - 09-15-2020 Also worth noting: keeping the Config.php file free from passwords and other credentials is good practice, especially when checking-in code in a versioning system. We use the .env file to set up stuff for development environment. The local environment is setup by the programmer and the CI/CO server inject the .env file for staging and production systems. RE: What's the difference between the .env file and App.php? - Codinglander - 02-20-2021 Just so that I understand correctly: If I fill the "App.php" configuration file LOCAL with the "live" data AND I have an .env file, then the .env file works LOCAL, right? If I then transfer my project to the server WITHOUT the .env file, will the data from the configuration folder take effect? RE: What's the difference between the .env file and App.php? - tgix - 02-21-2021 (02-20-2021, 08:03 PM)Codinglander Wrote: Just so that I understand correctly:Settings from the .env file will always overwrite your local settings from app/Config/*.php If no .env present, the settings from app/Config/*.php will be used. RE: What's the difference between the .env file and App.php? - paliz - 02-21-2021 Its quick acess to setting Use to enable env file edit. env |