Powered by AppSignal & Oban Pro

Phoenix Drills

exercises/phoenix_drills.livemd

Phoenix Drills

Mix.install([
  {:jason, "~> 1.4"},
  {:kino, "~> 0.9", override: true},
  {:youtube, github: "brooklinjazz/youtube"},
  {:hidden_cell, github: "brooklinjazz/hidden_cell"}
])

Navigation

Home Report An Issue Web ServersGroup Project: Blog

Phoenix Drills

Drills help you develop familiarity and muscle memory with syntax through repeated exercises. Unlike usual problems, Drills are not intended to develop problem solving skills, they are purely for developing comfort and speed.

This set of drills is for the Phoenix framework. Follow the instructions for each drill and complete them as quickly as you can.

Hello World

Create a hello world and replace any existing content on the "/" route with “Hello World”.

$ mix phx.new hello_world --no-ecto

Random Number

Create a random number web app that generates a random number between 1 and 100 on the "/random_number" route.

$ mix phx.new random_number --no-ecto

Phoenix Navigation

Create a Phoenix application multiple routes and a navigation bar.

$ mix phx.new navigation --no-ecto

Define three pages in router.ex such as “/home”, "/about", and "/projects". Each page should have it’s own controller such as HomeController, AboutController, and ProjectsController and display a simple text response.

Modify the existing root.html.heex file to include a link to each page.

You can use mix phx.routes to find the available paths and Path Helpers to link to the correct path.

<%= link "Home", to: Routes.home_path(@conn, :index) %>

Alternatively, you can use the static path, but it’s generally recommended to use Path Helpers because path helpers ensure we use actually defined routes.

<%= link "Home", to: "/home" %>

Counter

Previously in the Phoenix 1.6 reading material you walked through creating a counter application.

You’re going to create another Counter application, this time on your own without referring to the reading material (as much as possible). However, you are encouraged to reference the Phoenix and Phoenix HTML documentation.

$ mix phx.new counter --no-ecto

Store the current count in a GenServer or some other process under the application’s supervision tree. Render the current count on the "/" route. The user should be able to increment the count by pressing a button, and set the amount to increment the count by using a number input.

Make sure you do not overwrite any existing counter project.

Bonus: GitHub

Create a new GitHub repository for each of your Phoenix applications above and add them to your GitHub.

Commit Your Progress

DockYard Academy now recommends you use the latest Release rather than forking or cloning our repository.

Run git status to ensure there are no undesirable changes. Then run the following in your command line from the curriculum folder to commit your progress.

$ git add .
$ git commit -m "finish Phoenix Drills exercise"
$ git push

We’re proud to offer our open-source curriculum free of charge for anyone to learn from at their own pace.

We also offer a paid course where you can learn from an instructor alongside a cohort of your peers. We will accept applications for the June-August 2023 cohort soon.

Navigation

Home Report An Issue Web ServersGroup Project: Blog