Using Env to Modify an Environment
Env is a utility that can be used to modify a command's environment. It's a handy tool, but it can also cause problems.
The env utility obtains the current environment and modifies it according to its arguments, then invokes the utility named by its first operand with the modified environment. The resulting environment is written to the standard output, with one name=value pair per line.
It can also be used to add or remove an existing environment variable by setting its value to a new value. It's important to use a reduced PATH when modifying the environment, so that it doesn't get mixed up with other environments.
Using the env utility to set an environment can be dangerous, because you may have to change the value of a key directory or the path of the shell's commands. That can lead to errors, and you'll need to recompile your program to avoid breaking it.
For this reason, it's a good idea to keep an application's per-environment configuration separate from its per-install configuration, preferably in a read-only config file that's committed to Git, or in your database. That way, when you move the application to another environment, you'll only need to update your environment variables and you won't have to worry about recompiling the code base or the executable configuration file. And, if you want to keep the application's per-environment configuration unchanged, you can design it to be user-modifiable, so that values like site names or admin email addresses can be pushed from Git into your application's executable configuration file and then read from there by the end-user.