.env.laravel
This allows the web server to read but prevents other system users from viewing it.
Define a config value (e.g., config/services.my_api_key ), then use config('services.my_api_key') everywhere else. .env.laravel
| Mistake | Consequence | Solution | |---------|-------------|----------| | Committing .env to Git | Secret leak | Remove with git rm --cached .env and rotate secrets | | Using env() in views | Can break after config cache | Only use config() in application code | | Forgetting quotes for spaces | Variable truncated | Use double quotes: KEY="Multi word" | | Same .env for local & production | Accidental debug mode on live | Use APP_ENV=production and APP_DEBUG=false in production | | Editing .env directly on server (no backup) | Loss of configuration | Keep .env in a safe, backed-up location, use symlinks | This allows the web server to read but