Skip to content

Latest commit

 

History

History
128 lines (92 loc) · 6.88 KB

README.md

File metadata and controls

128 lines (92 loc) · 6.88 KB

Content

This boilerplate comes with batteries included, you’ll find:

Configurations

  • warnings_as_errors: true

Useful libraries

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

Rename your porject

  1. Open the script rename.sh
  2. Change NEW_NAME & NEW_OTP variables with your app name
  3. Execute the script sh rename.sh
  4. Remove the file rename.sh

Development with Docker

Dependencies

  1. Install Docker
  2. Install Make: sudo apt install make or brew install make

First run

  1. Clone the project repository: git clone [email protected]:Plus17/phoenix-boilerplate.git my_app
  2. Go to project dir: cd my_app
  3. Execute: make setup to install dependencies, setup the database, execute migrations, etc.
  4. Execute: make run to run the server at http://localhost:4000

New environment variables

If you want to add new environment variables you need to put the new env var in some places:

  1. In the .env.dist template file to include in new installations
  2. 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.

Makefile

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

Development without Docker

Dependencies

  1. Install asdf
  2. Add the asdf erlang plugin asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git
  3. Add the asdf elixir plugin asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git

First run

  1. Clone the project repository: git clone [email protected]:Plus17/phoenix-boilerplate.git my_app
  2. Go to project dir: cd my_app
  3. Install Erlang & Elixir according to the Dockerfile.dev file with: asdf install erlang 27.2 & asdf install elixir 1.18.1
  4. Run source .env on project root folder
  5. Run mix local.hex && mix local.rebar
  6. Run mix setup to download dependencies & setup database
  7. Run mix phx.server

New environment variables

If you want to add new environment variables you need to put the new env var in some places:

  1. In the .env.dist template file to include in new installations
  2. In your .env file.

AppName

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 with iex -S mix phx.server

Now you can visit localhost:4000 from your browser.

Ready to run in production? Please check our deployment guides.

Learn more