Get current environment name

前端 未结 4 1615
野性不改
野性不改 2020-12-28 15:49

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\")

4条回答
  •  孤城傲影
    2020-12-28 16:20

    Now in each environment config file (e.g. prod.exs) generated by default, you'll see the environment atom being set at the last line:

    config :your_app, :environment, :prod

    You can then use Application.get_env(:your_app, :environment) to get it.

    You can do the same in any custom environment config you create.

提交回复
热议问题