Phoenix in Action
Summary

Phoenix is a modern web framework built for the Elixir programming language. Elegant, fault-tolerant, and performant, Phoenix is as easy to use as Rails and as rock-solid as Elixir's Erlang-based foundation. Phoenix in Action builds on your existing web dev skills, teaching you the unique benefits of Phoenix along with just enough Elixir to get the job done.

Foreword by Sasa Juric, author of Elixir in Action, Second Edition.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Technology

Modern web applications need to be efficient to develop, lightning fast, and unfailingly reliable. Phoenix, a web framework for the Elixir programming language, delivers on all counts. Elegant and intuitive, Phoenix radically simplifies the dev process. Built for concurrency, Phoenix channels make short work of developing real-time applications. And as for reliability, Phoenix apps run on the battle-tested Erlang VM, so they're rock solid!

About the Book

Phoenix in Action is an example-based book that teaches you to build production-quality web apps. You'll handle business logic, database interactions, and app designs as you progressively create an online auction site. As you go, you'll build everything from the core components to the real-time user interactions where Phoenix really shines.

What's inside

  • Functional programming in a web environment
  • An introduction to Elixir
  • Database interactions with Ecto
  • Real-time communication with channels

About the Reader

For web developers familiar with a framework like Rails or ASP.NET. No experience with Elixir or Phoenix required.

About the Author

Geoffrey Lessel is a seasoned web developer who speaks and blogs about Elixir and Phoenix.

Table of Contents

    PART 1 - GETTING STARTED
  1. Ride the Phoenix
  2. Intro to Elixir
  3. A little Phoenix overview
  4. PART 2 - DIVING IN DEEP
  5. Phoenix is not your application
  6. Elixir application structure
  7. Bring in Phoenix
  8. Making changes with Ecto.Changeset
  9. Transforming data in your browser
  10. Plugs, assigns, and dealing with session data
  11. Associating records and accepting bids
  12. PART 3 - THOSE IMPORTANT EXTRAS
  13. Using Phoenix channels for real-time communication
  14. Building an API
  15. Testing in Elixir and Phoenix
1127522926
Phoenix in Action
Summary

Phoenix is a modern web framework built for the Elixir programming language. Elegant, fault-tolerant, and performant, Phoenix is as easy to use as Rails and as rock-solid as Elixir's Erlang-based foundation. Phoenix in Action builds on your existing web dev skills, teaching you the unique benefits of Phoenix along with just enough Elixir to get the job done.

Foreword by Sasa Juric, author of Elixir in Action, Second Edition.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Technology

Modern web applications need to be efficient to develop, lightning fast, and unfailingly reliable. Phoenix, a web framework for the Elixir programming language, delivers on all counts. Elegant and intuitive, Phoenix radically simplifies the dev process. Built for concurrency, Phoenix channels make short work of developing real-time applications. And as for reliability, Phoenix apps run on the battle-tested Erlang VM, so they're rock solid!

About the Book

Phoenix in Action is an example-based book that teaches you to build production-quality web apps. You'll handle business logic, database interactions, and app designs as you progressively create an online auction site. As you go, you'll build everything from the core components to the real-time user interactions where Phoenix really shines.

What's inside

  • Functional programming in a web environment
  • An introduction to Elixir
  • Database interactions with Ecto
  • Real-time communication with channels

About the Reader

For web developers familiar with a framework like Rails or ASP.NET. No experience with Elixir or Phoenix required.

About the Author

Geoffrey Lessel is a seasoned web developer who speaks and blogs about Elixir and Phoenix.

Table of Contents

    PART 1 - GETTING STARTED
  1. Ride the Phoenix
  2. Intro to Elixir
  3. A little Phoenix overview
  4. PART 2 - DIVING IN DEEP
  5. Phoenix is not your application
  6. Elixir application structure
  7. Bring in Phoenix
  8. Making changes with Ecto.Changeset
  9. Transforming data in your browser
  10. Plugs, assigns, and dealing with session data
  11. Associating records and accepting bids
  12. PART 3 - THOSE IMPORTANT EXTRAS
  13. Using Phoenix channels for real-time communication
  14. Building an API
  15. Testing in Elixir and Phoenix
38.99 In Stock
Phoenix in Action

Phoenix in Action

by Geoffrey Lessel
Phoenix in Action

Phoenix in Action

by Geoffrey Lessel

eBook

$38.99 

Available on Compatible NOOK devices, the free NOOK App and in My Digital Library.
WANT A NOOK?  Explore Now

Related collections and offers


Overview

Summary

Phoenix is a modern web framework built for the Elixir programming language. Elegant, fault-tolerant, and performant, Phoenix is as easy to use as Rails and as rock-solid as Elixir's Erlang-based foundation. Phoenix in Action builds on your existing web dev skills, teaching you the unique benefits of Phoenix along with just enough Elixir to get the job done.

Foreword by Sasa Juric, author of Elixir in Action, Second Edition.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Technology

Modern web applications need to be efficient to develop, lightning fast, and unfailingly reliable. Phoenix, a web framework for the Elixir programming language, delivers on all counts. Elegant and intuitive, Phoenix radically simplifies the dev process. Built for concurrency, Phoenix channels make short work of developing real-time applications. And as for reliability, Phoenix apps run on the battle-tested Erlang VM, so they're rock solid!

About the Book

Phoenix in Action is an example-based book that teaches you to build production-quality web apps. You'll handle business logic, database interactions, and app designs as you progressively create an online auction site. As you go, you'll build everything from the core components to the real-time user interactions where Phoenix really shines.

What's inside

  • Functional programming in a web environment
  • An introduction to Elixir
  • Database interactions with Ecto
  • Real-time communication with channels

About the Reader

For web developers familiar with a framework like Rails or ASP.NET. No experience with Elixir or Phoenix required.

About the Author

Geoffrey Lessel is a seasoned web developer who speaks and blogs about Elixir and Phoenix.

Table of Contents

    PART 1 - GETTING STARTED
  1. Ride the Phoenix
  2. Intro to Elixir
  3. A little Phoenix overview
  4. PART 2 - DIVING IN DEEP
  5. Phoenix is not your application
  6. Elixir application structure
  7. Bring in Phoenix
  8. Making changes with Ecto.Changeset
  9. Transforming data in your browser
  10. Plugs, assigns, and dealing with session data
  11. Associating records and accepting bids
  12. PART 3 - THOSE IMPORTANT EXTRAS
  13. Using Phoenix channels for real-time communication
  14. Building an API
  15. Testing in Elixir and Phoenix

Product Details

ISBN-13: 9781638356202
Publisher: Manning
Publication date: 04/26/2019
Sold by: SIMON & SCHUSTER
Format: eBook
Pages: 336
File size: 4 MB

About the Author

Geoffrey Lessel is a seasoned web developer who speaks and blogs about Elixir and Phoenix.
Geoffrey Lessel is a seasoned web developer who speaks and blogs about Elixir and Phoenix.

Table of Contents

Foreword xi

Preface xiv

Acknowledgments xvi

About this book xviii

About the author xxii

About the cover illustration xxiii

Part 1 Getting Started 1

1 Ride the Phoenix 3

1.1 What is Phoenix? 4

1.2 Elixir and Phoenix vs. the alternatives 5

Real-time communication 5

Efficient, small processes 6

Background computation 6

Minimal hardware requirements, low-cost scaling 7

It's not all roses 8

1.3 The power of Elixir 9

Scalability 9

Supervision trees 10

Erlang VM 11

Macro and metaprogramming support 12

OTP 12

1.4 Functional vs. object-oriented programming 13

Overview of functional programming 13

1.5 Keep reading 16

2 Intro to Elixir 17

2.1 The basics 18

IEx 19

Basic types 22

A small detour into functions 23

Data type details 27

Back to modules and named functions 34

Alias 36

Import 36

2.2 Other idiomatic Elixir language features 37

The pipe operator 37

Pattern matching 38

Using IEx.Helpers.v/1 43

3 A little Phoenix overview 45

3.1 Follow the data 47

The basics of a web request 47

Endpoint 48

Router 52

Controller 56

Views 61

Templates 62

3.2 Putting it all together 66

Part 2 Diving in deep 67

4 Phoenix is not your application 69

4.1 I thought this book was about Phoenix 70

4.2 The first steps in building your application 72

Defining an item 73

Adding a fake database 75

Getting an Item by id 79

Getting an Item based on other information 81

4.3 Next steps 84

5 Elixir application structure 86

5.1 Moving from a single file to an application 87

Using Mix to create a new application 88

Generating an auction umbrella application 90

The magic mix.exs file 92

5.2 Organizing, compiling, and running your new application 95

Breaking apart the three modules 96

Compile and run! 98

Running the Auction application for the first time 99

5.3 Using Hex to get external dependencies 100

Pulling in your dependencies 103

6 Bring in Phoenix 107

6.1 Installing Phoenix on your system 108

6.2 Creating a new Phoenix application 109

Running your server for the first time 110

6.3 Listing items from the fake repo 112

Modifying the controller and template 113

7 Being persistent with a database 119

7.1 A quick intro to Ecto 120

7.2 Configuring Ecto 120

Using Ecto's Mix tools to set up your database 123

7.3 Preparing Auction to use the database 123

Defining the Auction.Item schema 123

Migrating the database 125

Pointing the public interface to the new repo 128

Instructing the application to supervise the database connection 128

Testing it out 129

7.4 Creating, retrieving, and deleting data in the database 130

Inserting data 131

Retrieving data 133

Deleting data 134

Updating data 135

What about the website? 135

8 Making changes with Ecto.Changeset 137

8.1 Can't I just … update? 138

A brief intro to changesets 139

Creating a changeset for Auction.Item 139

8.2 Now you can update! 148

Adjusting the public interface for updating 150

9 Transforming data in your browser 152

9.1 Handling new routes in your application 153

Adding a new route 153

Adding a new controller 157

Adding a new view 158

Adding a new template 158

9.2 Viewing the details of a single item 160

Defining the show route and function 160

Defining the show.html template 162

Linking to individual items 162

9.3 Creating items through web forms 165

Defining the new and create routes 165

Defining the "new " controller function 166

Defining the "new" template 167

Defining the create controller function 168

9.4 Editing items through web forms 174

Defining the edit and update routes 174

Defining the "edit" controller function 175

Defining the edit.html.eex template 176

Defining Auction Web.ItemController.update/2 178

10 Plugs, assigns, and dealing with session data 181

10.1 Preparing your application for user registration 182

Defining the Auction. User schema 182

Creating a migration to create the users table 183

Defining changesets for Auction.User 184

Creating API functions in Auction 187

User registration web flow 188

10.2 Handling user login and sessions 192

Creating the route, controller, view, and templates for logging in and out 193

Implementing the dirty details of sessions and authentication 195

10.3 Plugs 200

10.4 Adding site navigation 202

Implementing the log out function 204

10.5 Restricting users from certain pages 205

11 Associating records and accepting bids 208

11.1 Creating bids 209

11.2 Adding associations to the Auction.Bid schema 210

A little detour into associations 210

Creating a migration that describes the associations 212

Creating a form to accept bids 217

11.3 Using has_many with items and users 222

Preloading and avoiding N+1 queries 223

Preloading associations in the public interface module and controller 226

Adding the list of bids to the view template 227

11.4 Listing a user's bids on their profile page 230

Using Ecto.Query to construct database queries 231

Making a view helper function global and using the bids assign 232

Using Timex to format dates and times 236

11.5 Some ideas for further improvement 237

Part 3 Those important extras 239

12 Using Phoenix channels for real-time communication 241

12.1 What are Phoenix channels? 242

12.2 Connecting a user to a channel and a topic 242

Handling topic join requests 243

Getting the user's browser to join a topic 244

12.3 Sending real-time messages to a user 251

Receiving messages in the user's browser 251

Configuring the channel to handle messages 252

Sending your browser a message from IEx 253

12.4 Updating all users when a new bid is made 254

Refactoring the rendering of an item's bids 255

Modifying the controller to broadcast a message 256

Handling the broadcasted HTML in the browser 258

13 Building an API 261

13.1 Scoping API requests to a new controller 262

13.2 Creating the Auction Web.Api.ItemController controller and view 264

13.3 Including related bid and user data 267

14 Testing in Elixir and Phoenix 271

14.1 An introduction to ExUnit 272

Writing a first test 273

14.2 Setting up tests for Ecto 275

Configuring a new database 275

Creating a sandbox and configuring Ecto to use it in tests 276

Setting up the database before tests run 277

Creating a Mix alias for use during test runs 278

14.3 Testing Ecto queries in Auction 279

Testing Auction.list_items/0 279

Testing Auction.get_item/1 281

Testing Auction.insert_item/1 282

14.4 Simultaneously writing documentation and tests with doctests 283

Writing function-level documentation 283

Viewing documentation in IEx 285

Viewing documentation with ExDoc 286

Adding examples and doctests 287

Module-level documentation 289

14.5 Writing tests For Phoenix 291

Testing that an item is added to the database on success 292

Testing that you're redirected to the new item on success 293

Testing that no item is created on error 294

Testing that the new item form is rendered on error 295

The entire ItemControllerTest module 295

14.6 What next? 296

Appendix A Installing Elixir and Phoenix 297

Appendix B More Elixir resources 300

Index 301

From the B&N Reads Blog

Customer Reviews