You can use them together. Config files provide configuration to the application. The config file can read environment variables, so you can deploy the same code across different environments, e.g., your local computer, staging, and production.
Then, each environment will provide system-related configuration, e.g., `DATABASE_URL`.
With this setup, the same code will work on each environment.
Now, .env files should live only on your local machine; on any other environment, they should be set differently, not in files.
The .env file is a convenience, but not the only option for environment variables, nowdays you can use 1Password too.
the_real_cher•1h ago