This boilerplate comes with batteries included, you’ll find:
- Phoenix
- Database integration with Ecto
- Translations with Gettext
- Static code analysis with Credo
- Releases using
mix release
and Docker - Tailwindcss
- [O]
- warnings_as_errors: true
Here is an opinionated list of other useful libraries to consider:
Category | Libraries |
---|---|
OAuth2 Authentication | ueberauth |
Token based auth | Guardian |
Safety migrations | strong_migrations |
HTTP client | Req |
Pagination | Scrivener (limit/offset), Flop Phoenix |
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 my_app
- Go to project dir:
cd my_app
- Execute:
make setup
to install dependencies, setup the database, execute migrations, etc. - Execute:
make run
to run the server at http://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 setup |
Setups the phoenix project (dependencies & database) |
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 ci |
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
- Clone the project repository:
git clone [email protected]:Plus17/phoenix-boilerplate.git my_app
- Go to project dir:
cd my_app
- Install Erlang & Elixir according to the
Dockerfile.dev
file with:asdf install erlang 27.2
&asdf install elixir 1.18.1
- Run
source .env
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