small medium large xlarge

Programming Phoenix: Productive |> Reliable |> Fast

by

Cover image for Programming Phoenix

Programming Phoenix

by

Don’t accept the compromise between fast and beautiful: you can have it all. Phoenix creator Chris McCord, Elixir creator José Valim, and award-winning author Bruce Tate walk you through building an application that’s fast and reliable. At every step, you’ll learn from the Phoenix creators not just what to do, but why. Packed with insider insights, this definitive guide will be your constant companion in your journey from Phoenix novice to expert, as you build the next generation of web applications.

Choose Your Format(s)

  • $47.00 In Stock

    Save $10.00 on the combo pack.

  • $34.00 In Stock
  • $23.00 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

About this Title

Skill-meter-4-6
Pages: 298
Published: 2016-04-10
Release: P1.0 (2016-04-27)
ISBN: 978-1-68050-145-2

Phoenix is the long-awaited web framework based on Elixir, the highly concurrent language that combines a beautiful syntax with rich metaprogramming. The authors, who developed the earliest production Phoenix applications, will show you how to create code that’s easier to write, test, understand, and maintain.

The best way to learn Phoenix is to code, and you’ll get to attack some interesting problems. Start working with controllers, views, and templates within the first few pages. Build an in-memory repository, and then back it with an Ecto database layer. Learn to use change sets and constraints that keep readers informed and your database integrity intact. Craft your own interactive application based on the channels API for the real-time, high-performance applications that this ecosystem made famous. Write your own authentication components called plugs, and even learn to use the OTP layer for monitored, reliable services. Organize your code with umbrella projects so you can keep your applications modular and easy to maintain.

This is a book by developers and for developers, and we know how to help you ramp up quickly. Any book can tell you what to do. When you’ve finished this one, you’ll also know why to do it.


Q&A with José Valim, creator of Elixir, and Chris McCord, creator of Phoenix.

José Valim, creator of Elixir, and Chris McCord, creator of Phoenix collaborated with Bruce Tate on Programming Phoenix. They took some time out of their busy days to answer a few questions about those two important inventions.

Q: José, why did you create Elixir?

A: Elixir was created out of a need for writing robust and concurrent software productively. In the last decade, our CPUs are not getting any faster, instead we are getting computers with more and more cores. This change in hardware is affecting how we write software and Elixir reflects that.

Q: José, why did you choose the Erlang VM for Elixir?

A: The Erlang VM is one of the few runtimes widely deployed in production that was designed for running network services. The Erlang VM provides the foundation that allows Phoenix to be extremely performant while holding 2 million open connections on a single machine. Elixir adds productive and expressive tooling to this robust runtime.

Q: José, was Elixir designed solely for the web?

A: Elixir was designed to be an extensible language. Throughout the book, we will see how Phoenix and Ecto effectively extend Elixir to provide fast request routing, elegant database queries and more. However, they are two of many examples. As Elixir adoption increases, we will continue to see it being brought to new domains, like data processing and embedded software.

Q: Chris, why did you write Phoenix?

A: I wanted a Web framework that could take on the modern Web’s realtime requirements of many connected devices. I found Elixir and realized it would allow a framework to be both highly productive and have world-class performance. Thus Phoenix was born.

Q: Chris, why is it better than what you used before?

A: Web frameworks that I had used before gave me the productivity I wanted, but I had to sacrifice performance to get a system that was a joy to program in. At the same time, most languages and frameworks I had experience in scaled very poorly when handling long-running, persistent connections. With Phoenix, we can handle millions of active connections on a single server in a language that is such a joy to use.

Q: Chris, what kinds of apps can benefit?

A: Any application requiring persistent connections is an obvious benefactor, but even standard HTML5 or JSON API applications see huge benefits when using Phoenix. Programmers often see microsecond response times when using Phoenix for HTML or JSON applications, and this directly results in heightened end-user experiences. We cover both types of applications in Programming Phoenix.

Read the reviews .

What You Need

To work through this book, you will need a computer capable of running Erlang 17 or better, Elixir 1.1, or better, Phoenix 1.0 or better, and Ecto 1.0 or better. A rudimentary knowledge of Elixir is also highly recommended.

Contents & Extracts

  • Introduction
  • Building with Functional MVC
    • The Lay of the Land
      • Simple Functions
      • Installing Your Development Environment
      • Creating a Throwaway Project
      • Building a Feature excerpt
      • Going Deeper: The Request Pipeline
      • Wrapping Up
    • Controllers, Views, and Templates
      • The Controller
      • Creating Some Users
      • Building a Controller
      • Coding Views
      • Using Helpers
      • Showing a User
      • Wrapping Up
    • Ecto and Changesets
      • Understanding Ecto
      • Defining the User Schema and Migration
      • Using the Repository to Add Data
      • Building Forms
      • Creating Resources
      • Wrapping Up
    • Authenticating Users
      • Preparing for Authentication
      • Managing Registration Changesets
      • Creating Users
      • The Anatomy of a Plug excerpt
      • Writing an Authentication Plug
      • Implementing Login and Logout
      • Presenting User Account Links
      • Wrapping Up
    • Generators and Relationships
      • Using Generators
      • Building Relationships
      • Managing Related Data
      • Wrapping Up
    • Ecto Queries and Constraints excerpt
      • Adding Categories
      • Diving Deeper into Ecto Queries
      • Constraints
      • Wrapping Up
    • Testing MVC
      • Understanding ExUnit
      • Using Mix to Run Phoenix Tests
      • Integration Tests
      • Unit-Testing Plugs
      • Testing Views and Templates
      • Splitting Side Effects in Model Tests
      • Wrapping Up
  • Writing Interactive and Maintainable Applications
    • Watching Videos
      • Watching Videos
      • Adding JavaScript
      • Creating Slugs
      • Wrapping Up
    • Using Channels
      • The Channel
      • Phoenix Clients with ES6
      • Preparing Our Server for the Channel
      • Creating the Channel
      • Sending and Receiving Events
      • Socket Authentication
      • Persisting Annotations
      • Handling Disconnects
      • Wrapping Up
    • OTP
      • Managing State with Processes
      • Building GenServers for OTP
      • Supervision Strategies
      • Designing an Information System with OTP
      • Building the Wolfram Info System
      • Wrapping Up
    • Observer and Umbrellas
      • Introspecting with Observer
      • Using Umbrellas
      • Wrapping Up
    • Testing Channels and OTP
      • Testing the Information System
      • Isolating Wolfram
      • Adding Tests to Channels
      • Authenticating a Test Socket
      • Communicating with a Test Channel
      • Wrapping Up
    • What’s Next?
      • Other Interesting Features
      • What’s Coming Next
      • Good Luck

Author

This is the team that drove the implementation of Elixir and Phoenix. Chris McCord, the creator of Phoenix, professionally trains new developers for the rising framework and works with teams adapting it. Bruce Tate, the author of many award-winning books and creator of the Seven Languages in Seven Weeks series, is the CTO for icanmakeitbetter.com, which is already running Phoenix in production. José Valim, the creator of Elixir and member of the Phoenix core team, is the co-founder and director of research and development at Plataformatec.