Programming Phoenix 1.4

Book description

Don't accept the compromise between fast and beautiful: you can have it all. Phoenix creator Chris McCord, Elixir creator Jose 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 and completely updated for Phoenix 1.4, 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.

Phoenix is the long-awaited web framework based on Elixir, the highly concurrent language that combines a beautiful syntax with rich metaprogramming. 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 context, and then back it with an Ecto database layer, complete with changesets 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 applications that this ecosystem made famous. Write your own authentication plugs, and use the OTP layer for supervised services. Organize code with modular umbrella projects.

This edition is fully updated for Phoenix 1.4, with a new chapter on using Channel Presence to find out who's connected, even on a distributed application. Use the new generators and the new ExUnit features to organize tests and make Ecto tests concurrent.

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.

What You Need:

To work through this book, you will need a computer capable of running Erlang 18 or higher, Elixir 1.5 or higher, and Phoenix 1.4 or higher. A rudimentary knowledge of Elixir is also highly recommended.

Publisher resources

View/Submit Errata

Table of contents

  1.  Acknowledgments
    1. José Valim
    2. Bruce Tate
    3. Chris McCord
  2.  Preface
    1. Is This Book for You?
    2. About this Book
    3. Online Resources
  3. 1. Introducing Phoenix
    1. Productive
    2. Concurrent
    3. Beautiful Code
    4. Interactive
    5. Reliable
  4. Part I. Building with Functional MVC
    1. 2. The Lay of the Land
      1. Simple Functions
      2. Installing Your Development Environment
      3. Creating a Throwaway Project
      4. Building a Feature
      5. Going Deeper: The Request Pipeline
      6. Wrapping Up
    2. 3. Controllers
      1. Understanding Controllers
      2. Building a Controller
      3. Coding Views
      4. Using Helpers
      5. Showing a User
      6. Wrapping Up
    3. 4. Ecto and Changesets
      1. Understanding Ecto
      2. Defining the User Schema and Migration
      3. Using the Repository to Add Data
      4. Building Forms
      5. Creating Resources
      6. Wrapping Up
    4. 5. Authenticating Users
      1. Preparing for Authentication
      2. Managing Registration Changesets
      3. Creating Users
      4. The Anatomy of a Plug
      5. Writing an Authentication Plug
      6. Implementing Login and Logout
      7. Presenting User Account Links
      8. Wrapping Up
    5. 6. Generators and Relationships
      1. Using Generators
      2. Building Relationships
      3. Managing Related Data
      4. In-context Relationships
      5. Wrapping Up
    6. 7. Ecto Queries and Constraints
      1. Seeding and Associating Categories
      2. Diving Deeper into Ecto Queries
      3. Constraints
      4. Wrapping Up
    7. 8. Testing MVC
      1. Understanding ExUnit
      2. Testing Contexts
      3. Using Ecto Sandbox for Test Isolation and Concurrency
      4. Integration Tests
      5. Unit-Testing Plugs
      6. Testing Views and Templates
      7. Wrapping Up
  5. Part II. Writing Interactive and Maintainable Applications
    1. 9. Watching Videos
      1. Watching Videos
      2. Adding JavaScript
      3. Creating Slugs
      4. Wrapping Up
    2. 10. Using Channels
      1. The Channel
      2. Phoenix Clients with ES6
      3. Preparing Our Server for the Channel
      4. Creating the Channel
      5. Sending and Receiving Events
      6. Socket Authentication
      7. Persisting Annotations
      8. Handling Disconnects
      9. Tracking Presence on a Channel
      10. Wrapping Up
    3. 11. Observer and Umbrellas
      1. Introspecting Applications with Observer
      2. Using Umbrellas
      3. Extracting Rumbl and RumblWeb
      4. Wrapping Up
    4. 12. OTP
      1. Managing State with Processes
      2. Building GenServers for OTP
      3. Designing an Information System with OTP
      4. Building the Wolfram Info System
      5. Integrating OTP Services with Channels
      6. Wrapping Up
    5. 13. Testing Channels and OTP
      1. Testing the Information System
      2. Isolating Wolfram
      3. Adding Tests to Channels
      4. Authenticating a Test Socket
      5. Communicating with a Test Channel
      6. Wrapping Up
    6. 14. What’s Next?
      1. Other Interesting Features
      2. Phoenix LiveView
      3. Phoenix PubSub 2.0
      4. Phoenix and Telemetry Integration
      5. Good Luck!

Product information

  • Title: Programming Phoenix 1.4
  • Author(s): Chris McCord, Bruce Tate, Jose Valim
  • Release date: October 2019
  • Publisher(s): Pragmatic Bookshelf
  • ISBN: 9781680502268