ðĶDirectory structure
If you had run the getting started instructions from the previous page, you would see the following directory structure for your project:
.
âââ .formatter.exs
âââ .gitignore
âââ README.md
âââ _build
âââ assets
â  âââ css
â  âââ js
â  âââ tailwind.config.js
â  âââ vendor
âââ config
â  âââ config.exs
â  âââ dev.exs
â  âââ prod.exs
â  âââ runtime.exs
â  âââ test.exs
âââ lib
â  âââ practical_elixir_demo
â  âââ practical_elixir_demo.ex
â  âââ practical_elixir_demo_web
â  âââ practical_elixir_demo_web.ex
âââ mix.exs
âââ mix.lock
âââ practical_elixir_demo_dev.db
âââ practical_elixir_demo_dev.db-shm
âââ practical_elixir_demo_dev.db-wal
âââ priv
â  âââ gettext
â  âââ repo
â  âââ static
âââ test
âââ practical_elixir_demo_web
âââ support
âââ test_helper.exs
Phoenix builds on top of the original folder structure that was discussed under the Mix section: Project structure. For more information about Phoenix's directory structure, refer to the official guide.
_build
: contains the compilation artifactsassets
: stores front-end assets like JavaScript and CSS; static assets like files go topriv/static
config
: common directory used to store project configurations (more information about order of config reading below)deps
: contains all Mix dependencies listed undermix.exs
underdeps/0
lib
: umbrella project for main application source code wherelib/practical_elixir_demo
holds the back-end logic (model) whilelib/practical_elixir_demo_web
holds the front-end logic (view and controller)priv
: all resources that are necessary in production but not a part of source code like database scripts, static resources, etc.test
: contains unit tests for application, similar structure aslib
The specific structure of each folder in lib/
will be discussed when we actually modify those files.
The file that end with *.db-*
are the SQLite3 files that maintain the database.
Config order
There are several configuration files that are used in Phoenix (or any Mix project for that matter) and in their read order:
config.exs
: base configurations declared for the project, these are read during compile timedev.exs
/prod.exs
/test.exs
: environment specific configurations that run only when the project is run in a given environment (during compile time as well)runtime.exs
: configurations that are run during runtime
runtime.exs
are the preferred method for loading environment variables from environment files like .env
while config.exs
are preferred for environment variables that may not be secrets and are readily accessible during compile time.
For more information about configuration files in Elixir, please refer to the official Elixir documentation for the Config
module.
Last updated