Phoenix Web Development
Mike Voloz, Brandon Richey
- 406 Seiten
- English
- ePUB (handyfreundlich)
- Über iOS und Android verfügbar
Phoenix Web Development
Mike Voloz, Brandon Richey
Über dieses Buch
Learn to build a high-performance functional prototype of a voting web application from scratch using Elixir and Phoenix
Key Features
- Build a strong foundation in Functional-Programming techniques while learning to build compelling web applications
- Understand the Elixir Concurrency and parallelization model to build high-performing blazingly fast applications
- Learn to test, debug and deploy your web applications using Phoenix framework
Book Description
Phoenix is a modern web development framework that is used to build API's and web applications. It is built on Elixir and runs on Erlang VM which makes it much faster than other options. With Elixir and Phoenix, you build your application the right way, ready to scale and ready for the increasing demands of real-time web applications.
This book covers the basics of the Phoenix web framework, showing you how to build a community voting application, and is divided into three parts. In the first part, you will be introduced to Phoenix and Elixir and understand the core terminologies that are used to describe them. You will also learn to build controller pages, store and retrieve data, add users to your app pages and protect your database. In the second section you will be able to reinforce your knowledge of architecting real time applications in phoenix and not only debug these applications but also diagnose issues in them. In the third and final section you will have the complete understanding of deploying and running the phoenix application and should be comfortable to make your first application release
By the end of this book, you'll have a strong grasp of all of the core fundamentals of the Phoenix framework, and will have built a full production-ready web application from scratch.
What you will learn
- Learn Phoenix Framework fundamentals and v1.3's new application structure
- Build real-time applications with channels and presence
- Utilize GenServers and other OTP fundamentals to keep an application stable
- Track users as they sign in and out of chat with Phoenix's built-in presence functionality
- Write your own database interaction code that is safe, bug-free, and easy to work with
- Explore testing and debugging methodologies to understand a real software development lifecycle for a Phoenix application
- Deploy and run your Phoenix application in production
Who this book is for
This book is for people with a basic knowledge of Elixir, who want to start building web applications. Prior experience with web technologies is assumed.
Häufig gestellte Fragen
Information
Storing and Retrieving Vote Data with Ecto Pages
- What the roles of schemas are in our application
- Creating new migrations
- How to write migrations
- Understanding the roles of contexts
- Hooking a context up to a controller
- Writing some basic unit tests to cover functionality
Understanding the role of schemas
poll = %{
title: "My First Poll",
options: [
{"Option 1", 0},
{"Option 2", 5},
{"Option 3", 1}
]
}
Poll | Title Options (reference to another table |
Option | Poll ID (reference to the poll this option is attached to) Title Votes |
Creating a new migration
$ mix help | grep ecto
mix ecto # Prints Ecto help information
mix ecto.create # Creates the repository storage
mix ecto.drop # Drops the repository storage
mix ecto.dump # Dumps the repository database structure
mix ecto.gen.migration # Generates a new migration for the repo
mix ecto.gen.repo # Generates a new repository
mix ecto.load # Loads previously dumped database structure
mix ecto.migrate # Runs the repository migrations
mix ecto.migrations # Displays the repository migration status
mix ecto.rollback # Rolls back the repository migrations
mix phx.new.ecto # Creates a new Ecto project within an umbrella project
$ mix help ecto.gen.migration
mix ecto.gen.migration
Generates a migration.
The repository must be set under :ecto_repos in the current app configuration
or given via the -r option.
## Examples
mix ecto.gen.migration add_posts_table
mix ecto.gen.migration add_posts_table -r Custom.Repo
The generated migration filename will be prefixed with the current timestamp in
UTC which is used for versioning and ordering.
By default, the migration will be generated to the "priv/YOUR_REPO/migrations"
directory of the current application but it can be configured to be any
subdirectory of priv by specifying the :priv key under the repository
configuration.
This generator will automatically open the generated file if you have
ECTO_EDITOR set in your environment variable.
## Command line options
• -r, --repo - the repo to generate migration for
Location: _build/dev/lib/ecto/ebin
Creating the Polls table migration
$ mix ecto.gen.migration add_polls_table
* creating priv/repo/migrations
* creating priv/repo/migrations/20171005161434_add_polls_table.exs
defmodule Vocial.Repo.Migratio...