This book is intended for developers with some previous experience, so installing these languages and tools shouldn't be overly difficult or time-consuming. Having said that, it's easy to get tripped up with installation and configuration steps, so feel free to create a GitHub issue if you think there's an easier approach to setting things up.
The intention for this chapter is to get everything we'll need installed quickly so we can start creating Phoenix projects.
These instructions assume that you're running macOS, but instructions can also be found online for installing these tools on Linux.
First, let's install Elixir with Homebrew. This command will also install the latest version of Erlang as a dependency:
$ brew install elixirYou can verify that Elixir has been installed properly by running the following command:
$ elixir -v
Erlang/OTP 20
Elixir 1.7.0Any trouble with this step? Check out the Elixir install page or the Elixir section of Stack Overflow.
Hex is the package manager for the Elixir and Erlang ecosystems. Once you have Elixir installed, it's easy to install Hex with the following command:
$ mix local.hexAny trouble with this step? Check out the Hex section of Stack Overflow.
Phoenix is a web application framework built with the Elixir language. You can install the latest version with the following command:
$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ezYou can verify that Phoenix has been installed properly by running the
mix help command, and you should be able to see a mix phx.new task that will
allow us to create new Phoenix applications.
Any trouble with this step? Check out the Phoenix installation docs or the Phoenix section of Stack Overflow.
We'll be using PostgreSQL for our database. The
easiest way to get started if you're new to PostgreSQL is to use
Postgres.app. It's a macOS application that
makes it really simple to get PostgreSQL up and running, and also creates a
postgres user that Phoenix uses as a default when creating databases.
Any trouble with this step? Check out the PostgreSQL detailed installation guides or the PostgreSQL section of Stack Overflow.
The steps above should be all that's required to get started. If you're interested in working with multiple versions different languages, check out the asdf version manager.
Throughout this book, we opt for a simple approach to afford ourselves an opportunity to learn about Elixir, Phoenix, and Elm as we put together a demo application. As you start to develop more involved projects, it's a good idea to review additional tools and services that can make your life easier.
The hex.pm package manager is an invaluable tool for finding useful libraries for your projects. For example, if you want to allow your users to write Markdown syntax, you can look up "Markdown" on hex.pm and find that the Earmark package works really well for this.
Listed below are additional tools for your consideration.
Want to build more robust authentication features for your application? Consider checking out the following options:
We briefly touched on authorizing actions in our demo application. If you need to work with additional authorization policies, take the following into consideration:
Credo is a code quality tool that performs static analysis on your Elixir code and provides helpful tips and feedback. It's really helpful as a way to learn solid Elixir conventions and keep the code throughout your project consistent.
Elixir has amazing documentation tools, which explains why the docs are so
fantastic. Check out the Elixir guide on
writing documentation
and consider using ExDoc to generate docs for your project.
Early versions of this book included material on Continuous Integration and Continuous Delivery. Although it ended up being outside the scope of our content, it's essential to have a CI server to automatically run your tests. Check out the following options, and consider hooking them into your GitHub repository to automatically deploy your application.
Once your project is deployed to production, it's a good idea to monitor the performance and watch for errors. AppSignal is a good option for tracking this data and keeping your application running smoothly.
Because we used the Phoenix generators to scaffold out our initial features,
our demo application came with quite a few tests. So we have examples of how
to work with ExUnit in our project, but Wallaby is a great option for writing
highly readable integration tests concurrently.