
Create a new project
Let’s clone the project.
git clone https://github.com/PhoenixBasics/fawkes.git
Don’t navigate into the project. From where we clone the repo, let’s create a new project named fawkes
, type:
mix phx.new fawkes
When asked to continue because the folder exist, type y
to say yes. The above command will generate the Phoenix application for us. After the file creation, it will ask us to fetch and install dependencies. Type y
.
Fetch and install dependencies? [Yn] y
By saying yes, these commands will be run for us:
This commands downloads our dependencies:
mix deps.get
Phoenix uses Brunch.io for asset management by default. Brunch.io’s dependencies are installed via the node package manager, not mix. This command will install our node dependencies:
cd assets && npm install && node node_modules/brunch/bin/brunch build
This compiles the project:
mix deps.compile
Note that Phoenix will auto-reload our code for us so we don’t have to run compile every time we make a file change.
Running the server
After the application installed our dependencies, it tells us what to do next.
- Change into our project directory
cd fawkes
- Open the application in our editor
- Open the file
config/dev.exs
and ensure the username and password for Postgres is correct. - Ecto allows our Phoenix application to communicate with a data store – PostgreSQL in this case. Create our database from the command line by running:
mix ecto.create
- Start our server
mix phx.server
- Open http://localhost:4000 in a browser.
Congratulations, we got a server!!!
Prettifying the page
Merge in the assets branch to get the assets for our application.
git merge assets