@@ -4,8 +4,8 @@ defmodule Config do
44
55 ## Example
66
7- This module is most commonly used to define application
8- configuration, typically in `config/config.exs`:
7+ This module is most commonly used to define application configuration,
8+ typically in `config/config.exs`:
99
1010 import Config
1111
@@ -18,14 +18,20 @@ defmodule Config do
1818 `import Config` will import the functions `config/2`, `config/3`
1919 and `import_config/1` to help you manage your configuration.
2020
21- Once Mix starts, it will automatically evaluate the configuration
22- file and persist it into `:some_app`'s application environment, which
23- can be accessed in as follows:
21+ `config/2` and `config/3` are used to define key-value configuration
22+ for a given application. Once Mix starts, it will automatically
23+ evaluate the configuration file and persist the configuration above
24+ into `:some_app`'s application environment, which can be accessed in
25+ as follows:
2426
2527 "value1" = Application.fetch_env!(:some_app, :key1)
2628
27- See `Config.Reader` for evaluating and reading configuration
28- files.
29+ Finally, the line `import_config "#{Mix.env()}.exs"` will import other
30+ config files, based on the current Mix environment, such as
31+ `config/dev.exs` and `config/test.exs`.
32+
33+ `Config` also provides a low-level API for evaluating and reading
34+ configuration, under the `Config.Reader` module.
2935
3036 **Important:** if you are writing a library to be used by other developers,
3137 it is generally recommended to avoid the application environment, as the
@@ -34,17 +40,16 @@ defmodule Config do
3440
3541 ## Migrating from `use Mix.Config`
3642
37- The `Config` module in Elixir was introduced in v1.9 as a
38- replacement to `Mix.Config`, which was specific to Mix and
39- has been deprecated.
43+ The `Config` module in Elixir was introduced in v1.9 as a replacement to
44+ `Mix.Config`, which was specific to Mix and has been deprecated.
4045
41- You can leverage `Config` instead of `Mix.Config` in two steps.
42- The first step is to replace `use Mix.Config` at the top of
43- your config files by `import Config`.
46+ You can leverage `Config` instead of `Mix.Config` in two steps. The first
47+ step is to replace `use Mix.Config` at the top of your config files by
48+ `import Config`.
4449
45- The second is to make sure your `import_config/1` calls do
46- not have a wildcard character. If so, you need to perform
47- the wildcard lookup manually. For example, if you did:
50+ The second is to make sure your `import_config/1` calls do not have a
51+ wildcard character. If so, you need to perform the wildcard lookup
52+ manually. For example, if you did:
4853
4954 import_config "../apps/*/config/config.exs"
5055
@@ -54,6 +59,15 @@ defmodule Config do
5459 import_config config
5560 end
5661
62+ ## config/releases.exs
63+
64+ If you are using releases, see `mix release`, there another configuration
65+ file called `config/releases.exs`. While `config/config.exs` and friends
66+ mentioned in the previous section are executed whenever you run a Mix
67+ command, including when you assemble a release, `config/releases.exs` is
68+ execute every time your production system boots. Since Mix is not available
69+ in a production system, `config/releases.exs` must not use any of the
70+ functions from Mix.
5771 """
5872
5973 @ config_key { __MODULE__ , :config }
0 commit comments