ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - phoenixframework/ex_conf: Simple Elixir Configuration Management
Simple Elixir Configuration Management. Contribute to phoenixframework/ex_conf development by creating an account on GitHub.
Visit Site

GitHub - phoenixframework/ex_conf: Simple Elixir Configuration Management

GitHub - phoenixframework/ex_conf: Simple Elixir Configuration Management

ExConf

Simple Elixir Configuration Management

Deprecated

ExConf has been replaced by Mix Configuration. See the Phoenix README for new configuration instructions.

Features

  • Configuration definitions are evaluated at runtime, but merged/defaulted at compile time, allowing runtime dependent lookups. (i.e. System.get_env)
  • Configuration modules can extend other configurations for overrides and defaults
  • Evironment based lookup for settings based on provided env_var

Simple Example


defmodule MyApp.Config do
  use ExConf.Config

  config :router, ssl: true,
                  domain: "example.dev",
                  port: System.get_env("PORT")

  config :session, secret: "secret"
end

iex> MyApp.Config.router[:domain]
"example.dev"


defmodule MyApp.OtherConfig do
  use MyApp.Config

  config :session, secret: "123password"
end

iex> MyApp.OtherConfig.session[:secret]
"123password"
iex> MyApp.OtherConfig.router[:ssl]
true

Environment Based Configuration

First, establish a base configuration module that uses ExConf.Config and provide an env_var option for System.get_env lookup at runtime of the current application environment.

defmodule MyApp.Config do
  use ExConf.Config, env_var: "MIX_ENV"

  config :router, ssl: true
  config :twitter, api_token: System.get_env("API_TOKEN")
end

Next, define "submodules" for each environment you need overrides or additional settings for. The base config module will look for a "submodule" whos name is the value of :env_var fetched from System.get_env in capitalized form. This allows environment specific lookup at runtime via the env/0 function on the base module. If the environment specific config module does not exist, it falls back to the base module.

Here's what a Dev enviroment config module would look like for System.get_env("MIX_ENV") == "dev":

defmodule MyApp.Config.Dev do
  use MyApp.Config

  config :router, ssl: false
  config :twitter, api_token: "ABC"
end

iex> System.get_env("MIX_ENV")
"dev"

iex> MyApp.Config.env
MyApp.Config.Dev

iex> MyApp.Config.env.router[:ssl]
false

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory