How to grab error code when .env file does not exist?
Hello, I would like my package to handle the Laravel request when .env file does not exist in the application directory and the web server sends the 500 error. Should I use both controller and view for this purpose or I have to register an Exception Handler?
You'd probably have to do it in /public/index.php or something before laravel bootstraps itself, since laravel pulls data from .env if the /config file values aren't hardcoded and referencing env(). That would most likely error out before your package even gets loaded. Like, let's say it was a new laravel install and they didn't even have a .env. Laravel would error out because it can't connect to the db and stuff.
Who says that an .env has to exist? This is an unsafe assumption since ideally you would never use .env in production. It is only a substitute for web server environment variables during development.
@Snapey: OK, now if I run the command php artisan config:cache for deploying my application to production I still get the 500 error message from the server when .env file does not exist in the root of the application directory. So I guess I have overlooked some basic information about the deployment procedure, but what?
Thanks for all the replies