This boilerplate comes with batteries included, you’ll find:
- Phoenix
- Database integration with Ecto
- Translations with Gettext
- Tests factories using ExMachina and code coverage using ExCoveralls
- CORS management with CorsPlug
- Static code analysis with Credo
- Releases using
mix release
and Docker - Tailwindcss
- warnings_as_errors: true
Here is an opinionated list of other useful libraries to consider:
Category | Libraries |
---|---|
Authentication | ueberauth |
Token based auth | Guardian |
Emails | bamboo , swoosh |
HTTP client | Tesla |
Job processing | Oban |
Pagination | Scrivener (limit/offset), Quarto (cursor based) |
Mocks | Mox , Mimic |
Cache | Cachex, Nebulex (distributed cache) |
Date/Time | Timex |
CSV | NimbleCSV, CSV |
Feature Flags/Toggles | FunWithFlags |
Clustering | libcluster |
- Open the script
rename.sh
- Change
NEW_NAME
&NEW_OTP
variables with your app name - Execute the script
sh rename.sh
- Remove the file
rename.sh
- Install Docker
- Install Make:
sudo apt install make
orbrew install make
- Clone the project repository:
git clone [email protected]:Plus17/phoenix-boilerplate.git
- Go to project dir:
cd phoenix-boilerplate
- Execute:
make setup
to install dependencies, setup the database, execute migrations, etc. - Get a
.env
file executingcp env.template .env
and set theSECRET_KEY_BASE
value. Get a new value executingmake gen.secret
- Execute:
make run
to run the server at https://localhost:4000
If you want to add new environment variables you need to put the new env var in some places:
- In the
.env.dist
template file to include in new installations - In your
.env
file
NOTE: When you add a new env var you must restart the container, so the container can read the new variable.
For convenience, you can use the commands included in the Makefile:
Command | Description |
---|---|
make bootstrap |
Bootstrap the phoenix project (dependencies & databse) |
make deps.get |
Gets & compile dependencies |
make deps.clean |
Clean unused dependencies & remove from mix.lock |
make seeds |
Run seeds |
make reset |
Resets the project removing deps & builds |
make ecto.setup |
Setup the database for dev |
make ecto.reset |
Resets the database for dev |
make ecto.reset.test |
Resets the database for test |
make test |
Runs tests |
make check.all |
Run all CI verifications (formatter, credo, coverage) |
make run |
Start Phoenix server |
make gettext |
Search & merge new translations |
make format |
Format all phoenix files |
- Install asdf
- Add the asdf erlang plugin
asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git
- Add the asdf elixir plugin
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
- Install fnm
curl -fsSL https://fnm.vercel.app/install | bash
- Clone the project repository:
git clone [email protected]:Plus17/phoenix-boilerplate.git my_app
- Go to project dir:
cd my_app
- Install Erlang, Elixir & NodeJS using the
.tools-versions
file with:asdf install
- Install NodeJs usign the
.node-version
file withfnm install
- Copy the
env.dist
file to.env
and set theSECRET_KEY_BASE
value. Get a new value executingmix phx.gen.secret
. - Run
export $(cat .env | xargs)
on project root folder - Run
mix local.hex && mix local.rebar
- Run
mix setup
to download dependencies & setup database - Run
mix phx.server
If you want to add new environment variables you need to put the new env var in some places:
- In the
.env.dist
template file to include in new installations - In your
.env
file.
To start your Phoenix server:
- Install dependencies with
mix deps.get
- Create and migrate your database with
mix ecto.setup
- Start Phoenix endpoint with
mix phx.server
or inside IEx withiex -S mix phx.server
Now you can visit localhost:4000
from your browser.
Ready to run in production? Please check our deployment guides.
- Official website: https://www.phoenixframework.org/
- Guides: https://hexdocs.pm/phoenix/overview.html
- Docs: https://hexdocs.pm/phoenix
- Forum: https://elixirforum.com/c/phoenix-forum
- Source: https://github.com/phoenixframework/phoenix