Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phoenix equivalent of Rails.env.production?

I'm new to phoenix and elixier but the framework looks very interesting. Currently i'm searching for an equivalent of Rails environment helpers.

Rails.env.production?
Rails.env.staging?

is there a similar implementation in phoenix ?

Best Regards

Eric

like image 353
bulleric Avatar asked Feb 12 '16 11:02

bulleric


2 Answers

This function is not a part of the PhoenixFramework. Elixir's Mix supports three types of environment

Mix.env hold the current stage and give a result of :dev, :test, or :prod. The develop option is used by default. On tests (mix test) the test environment will be automatically used.

This console call MIX_ENV=prod mix compile will compile the files in production environment.

See Introduction to mix for more information.

like image 168
Fabi755 Avatar answered Oct 19 '22 22:10

Fabi755


In addition to what Fabi755 said you may also interact with the different environments through the Application module. There are functions like Application.get_env/2 which can fetch the same configuration based on the environment you are currently in (like let's say have a config for sending SMS to false in dev, but you have it to true in prod).

Ultimately the environments are not from Phoenix but from Elixir and the Mix tool.

like image 20
Sasha Fonseca Avatar answered Oct 19 '22 23:10

Sasha Fonseca