Handling environments using .env |
I started with an .htaccess that was pretty standard:
Code: RewriteEngine On I know CI4 comes with its own .htaccess, but they can sometimes be finicky, so I thought I'd test out using a different one. Per documentation here: https://bcit-ci.github.io/CodeIgniter4/g...s.html#env Seems like I should be able to add this to my .env: Code: CI_ENVIRONMENT = development and then CodeIgniter should start displaying errors instead of "whoops". This does not work for me. The only way I can change the environment to development is with this line in .htaccess: Code: SetEnv CI_ENVIRONMENT development So, then I noticed that the env file in root directory is not prefixed with a dot. I added the dot, but still no love. After that I swapped out my .htaccess file for the one provided by CI4, but still not love. On this page https://bcit-ci.github.io/CodeIgniter4/g...ation.html it seems to indicate that nothing else should need to be done: Quote:When your application runs, this file will be automatically loaded and the variables will be put into the environment. This will work in any environment. If it matters, this is a Ubuntu 16.04 / PHP 7.2 server. What does one do to get the .env file to work? Please point to documentation if available.
By default you receive .htaccess file inside the public folder which has
Code: SetEnv CI_ENVIRONMENT development If you comment it with # then the value from .env will be used. To be honest I think that it is not logical .env to be after htaccess but as .env is per instance while the .htaccess is usually stored inside the git repo... Best VPS Hosting : Digital Ocean
(09-29-2018, 06:55 AM)sv3tli0 Wrote: By default you receive .htaccess file inside the public folder which has This is what I expect, but is not working. (09-29-2018, 07:18 AM)skunkbad Wrote:(09-29-2018, 06:55 AM)sv3tli0 Wrote: By default you receive .htaccess file inside the public folder which has CI_ENVIRONMENT=production And at the first page it shows production ![]() Best VPS Hosting : Digital Ocean
Yes I got confused with the same i.e. I tried to set the CI_ENVIRONMENT in .env file but it didn't work because I didn't realise it was being set in the public/.htaccess. As mentioned above, I simply commented that out and it works fine now. I suppose it should be made clearer in the documentation.
The only thing that may be wrong at this case is that we have by default Setenv in the .htaccess ..
By default it should be set inside the env file to development . Best VPS Hosting : Digital Ocean
I can't make it work for me too.
I didn't understand the solution to change to development mode. I opened the env file and changed to: Code: #-------------------------------------------------------------------- But when error occurs, it shows me the Whoops message. The documentation says that the only change that we have to do is in .env file... And I couldn't find no SetEnv on the .htaccess files, inside public and inside app.
You need to make a copy of your "env" file and name it ".env". The . (dot) are required.
PS. This thread are from 2018, a lot have changed since then. So it may not be in the file itself, but you can add it to .htaccess. |
Welcome Guest, Not a member yet? Register Sign In |