In Phoenix Framework, how can I get the current environment\'s name ?
I\'ve already tried reading env
variables with System.get_env(\"MIX_ENV\")>
An alternative to putting the Mix.env/0
into your applications configuration is to use a module attribute. This also works in production because module attributes are evaluate at compile time.
defmodule MyModule do
@env Mix.env()
def env, do: @env
end
If you only need the environment in a specific place - for example when starting up the application supervisor - this tends to be the easier solution.