Enux (enux v0.5.0) View Source
A package for reading variables from env style and json configuration files and injecting them into your application.
Installation
def deps do
[
{:enux, "~> 0.5.0"},
# if you want to load json files, you should have either this
{:jason, "~> 1.2"},
# or this
{:poison, "~> 4.0"}
]
end
Usage
In elixir 1.11, config/runtime.exs
was introduced. This is a file that is executed exactly before your application starts.
This is a proper place to load any configuration variables into your app. If this file does not exist in your project directory,
create it and add these lines to it:
import Config
env = Enux.load()
config :otp_app, env
When you start your application, you can access your configuration variables using Applicatoin.get_env
.
If you need to url encode your configuration values, just pass url_encoded: true
to Enux.load
.
You should have either poison or jason in your dependencies if you want to use json files.
You can load multiple files of different kinds:
import Config
env1 = Enux.load("config/one.env", url_encoded: true)
config :otp_app, env1
env2 = Enux.load("config/two.json")
config :otp_app, env2
Link to this section Summary
Functions
reads the variables in config/.env
and returns a formatted keyword list.
all values are loaded as they are.
reads the variables in config/.env
and returns a formatted keyword list
reads the variables in the given path(could be .env or .json file) and returns a formatted keyword list
Link to this section Functions
reads the variables in config/.env
and returns a formatted keyword list.
all values are loaded as they are.
reads the variables in config/.env
and returns a formatted keyword list
reads the variables in the given path(could be .env or .json file) and returns a formatted keyword list