Learn how to use the Phoenix Framework to
enjoy building real-time web/mobile apps
that are fast for "end-users", reliable,
scalable, maintainable and easily extensible!
As web/mobile app developers we need to leverage
the work that other (really smart) people have done
instead of constantly building things "from scratch" all the time;
that is why we use frameworks to build our apps!
See: "Top 10 Reasons Why Phoenix" (further down this page!)
There are many frameworks to choose from
(a few popular ones are mentioned below
in the Questions section).
But if we go by what is "popular" we'd
still be riding horses (and carts) everywhere
and no progress would be made.
Note: all the reasons "Why" for
Elixiralso apply toPhoenix!
check them out: dwyl/learn-elixir#key-advantages
A web application framework without compromise!
The biggest "constraint" in any technology project is people. An "Entrepreneur"/"Founder" or "Product Owner" can have all the good ideas in the world, if they are unable to convert idea into reality, it's meaningless.
Obviously, you should run your own benchmarks on your own hardware/cloud and make informed decisions based on the requirements of your app/product, but ... when we read the stats for how many concurrent users a Phoenix App can handle (with live WebSocket connections) we were blown away! It means we can build our real-time app(s) with 90% fewer resources.
- considerably lower latency and request response time than anything else! (thanks to Erlang's lightweight processes and ultra-efficient network/message handling)
- 4x more requests-per-second than the
equivalent
Node.js(Express.js) App. - 9x more throughput than a
Pythonbased app. (blocking really sucks!) - 10x - 100x more requests handled than
Ruby-on-Rails(depending on the type of app!) - Similar performance to Go on a single server, but a much simpler multi-server concurrency model, so horizontal scaling across multiple data centers ("availability zones") is much easier! (Erlang manages the resources for multiple servers/processors as a single app "fleet" and delegates requests/processing to them across clusters/zones!)
All of this means that you spend considerably less money on Hardware/Cloud infrastructure so your app/company can gain a competitive advantage on cost.
If you are in the fortunate position to be considering using something way better for your next project, look no further than Phoenix!
Read more: phoenixframework.org
Where there is a specific high-performance function needed
the BEAM VM also makes it easy
to integrate Elixir with lower-level code.
There are libs that make this easy,
such as Rustler (for Rust) and Zigler (for Zig).
Many people/teams/companies are already
using Erlang/Elixir and Phoenix and seeing phenomenal results!
Including: Adobe, BBC, Spotify, Pinterest, Discord (Gamer Chat App),
Groupon (Fave), Lonely Planet, Brightcove, Slack ...
See:
/elixir-companies
- People who want an easy way of building an app with all the modern conveniences of "generators", built-in Database interface ("ORM") and Firstclass WebSockets for "real-time" while getting legendary reliability.
- Teams who need the developer productivity or
Ruby-on-RailsorDjango, but want less "magic" (i.e. want to understand how everything works!). - Companies who want to spend 90% less on both developer and infrastructure costs so you can serve more people with fewer resources.
- Anyone who needs to use the "most popular" framework or language (for whatever reason).
- Companies who already have lots of legacy
Java/PHP/ etc. and cannot invest the time to learn/use something new. - Developers who want "job security" bug-fixing unreliable code.
The only recommended learning before diving into Phoenix
is learning Elixir.
You cannot build a Phoenix App without knowing Elixir.
If you are new to Elixir, "star" (bookmark) this repo
(so you can return to it tomorrow)
and then go to:
dwyl/learn-elixir
learn Elixir until you feel like you understand the syntax,
then come back and learn Phoenix!
Specifically you should focus on learning the Elixir "Basics":
- types of data
- atoms
- pattern matching
- maps
- function definitions
- modules
If you've already learned some Elixir, then
the first step to getting started with Phoenix is installation!
The Phoenix documentation is amazing, so we recommend following the
official phoenix installation instructions
You'll also need to install PostgreSQL,
there is a tutorial of how to do so
linked in the Phoenix installation guide linked above, but you can also check
out our
learn-postgresql
repo
for instructions, and raise an issue if you have any trouble!
While a basic understanding of JavaScript can be useful at times,
you don't need it to use Phoenix.
Familiarize yourself with the "Up and Running" (official) guide:
https://hexdocs.pm/phoenix/up_and_running.html#content

Once you have phoenix installed
and followed the official "up and running" guide,
come back and try these beginner-friendly examples:
- Counter (realtime shared counter using Phoenix LiveView): https://github.com/dwyl/phoenix-liveview-counter-tutorial
- Todo List (step-by-step tutorial showing how to build a fully functional TodoMVC clone): https://github.com/dwyl/phoenix-todo-list-tutorial
- Chat (realtime UI/UX using WebSockets): https://github.com/dwyl/phoenix-chat-example
- Encryption (security): https://github.com/dwyl/phoenix-ecto-encryption-example
- Append-only Log (how to store your App's data): https://github.com/dwyl/phoenix-ecto-append-only-log-example
When we started learning Pheonix in 2015,
there was only one book written by
@chrismccord creator of Phoenix:
Programming Phoenix
Sadly, Chris has been too busy building Phoenix
and the book hasn't been updated recently,
so it's quite out-of-date.
Luckily in the intervening years, several great books have been published on the topic: pragprog.com/search/?q=phoenix
Any of these books is a good starting point.
Our comprehensive free tutorials are also a great starting point.
Code to the Moon (@MoonKraken)
has a superb (recent) intro to Phoenix
from the perspective of a Rust engineer with many decades of experience:
"The Most Admired Web Framework":
youtu.be/RNMwz5n1M80
There are many more superb Elixir and Phenix videos on YouTube
search is your friend:
youtube.com/results?search_query=phoenix+1.8
Note: remember to include the latest version of
Phoenixin your query to get the latest results.
"Phoenix provides the productivity of Ruby-on-Rails
with the concurrency and fault-tolerance of Erlang."
-
Beyond all the (fantastic) technical benefits, what attracts us to
Phoenixis the Great Community of people around the world who are excited about makingPhoenixan amazing tool for building web apps!
Having welcomming people who will:- help you when you get stuck, patiently explaining things
- answer questions (both "noob" and "advanced") and
- openly discuss (your) ideas for improvements.
-
Phoenix uses the
Elixirprogramming language which means your app is compiled and run on theErlangVirtual Machine "BEAM".
Erlangis a battle-tested highly fault-tolerant VM used by many telecommunications companies -
WebSockets ("channels") are a first-class citizen of framework which means building apps with "real-time" communication and interaction is much easier than virtually any other framework/platform! (no third-party
magicmodule needed! everything you need is already there ready for you to serve millions of people!!)
see: phoenixframework.org/docs/channels -
Easy asyncrhonisity because all programming in Phoenix (Elixir) is Functional! This means it's really simple to abstract useful functionality like request authentication, logging and processing into "piplines" that are easily human-readable! (no third-party
asyncmodule required! no "promises", "generators" or "observables" to managed!!) -
Security & Resilience Mindset is the
default. Encryption (SSL) is easy in Phoenix/Elixir and both mitigation of SQL injection, Cross-site Scripting (XSS) and CSRF protection are built-in (enabled bydefault) so it's virtually impossible for a "novice" programmer to introduce this type of security bug. -
Concise Code cannot be understated! We can write way fewer lines than in the equivalent Node.js/Java/Rails/Go app, this means developers are more productive and there is less code to maintain!
-
Testability due to functional programming of all controllers!
-
Easy Deployment: fly.io/docs/elixir/getting-started/
-
Zero-downtime Deployment is free! (again because of
Erlang).Erlangmanages transitioning "live/active" users from the old to new version of your app without them even noticing that it was upgraded/updated!! -
Built-in Monitoring / Management of your app through
Erlangsupervisors mean that you know exactly how your app is performing, what parts have crashed/restarted and why! This is a feature we pay (a lot) for in other frameworks and here it's free!!
Can you think of another reason
why using Phoenix is awesome?!
Please Share your thoughts in this thread:
dwyl/learn-phoenix-framework#13
Yes. See: https://github.com/dwyl/learn-elixir
No. You can start learning/using Elixir today and
call Erlang functions when required,
but you don't need to know Erlang
before you can use Phoenix!
There are many web application frameworks
you/we can choose from:
wikipedia.org/wiki/Comparison_of_web_frameworks
So why would anyone select a framework written in a programming language
that is not mainstream...?
This is missinformation.
We are still using Hapi.js
for a number of projects where it is appropriate.
This includes several client projects
and internal dwyl apps/tools.
We decided to use Phoenix
for our new projects for these simple reasons:
Elixiris a nicer language thanJavaScript.JScan be functional, whereasElixiris (always) Functional! The distinction makes all the difference!
With "functional" programming, the programs are a lot easier to think about while you are writing/maintaining them!Elixiruses theErlangVM which is way more efficient/powerful than "V8"- The
ErlangVM scales much easier to multi-core multi-server multi-data-center thanNode.js
(or pretty much anything else for that matter!!)
For our new projects we need multi-data-center fault-tolerance!
we get that "for free" by using Erlang -> Elixir -> Phoenix!!
In our opinion Hapi.js is still "the best" Node.js framework and
we will continue to use and recommend it
to people that need simple apps that scale and are easy to maintain.
see:
dwyl/learn-hapi
Also we still use JavaScript for all our AWS Lambda Micro-Services,
that is not going to change.
They are simple, efficient and
scale really well!
see: https://github.com/dwyl/learn-aws-lambda
The original "productive" web frameworks
were "Ruby-on-Rails" and "Django" (python) back in 2005!
(We used both of these for periods in our "journey" and
can speak on the advantages of each of them!)
There is "nothing wrong" with using
RailsorDjango.
We think there are still plenty of use-cases for both frameworks.
We just know that it's (a lot) easier to build "real-time"
with Phoenix because "Channels" (WebSockets) are baked in,
and the Elixir/Erlang concurrency is a whole different ballgame!
Erlang (and thus Phoenix) can handle millions of concurrent users on a single server,
whereas a Rails/Django server can only handle a few thousand (at best!)
if your app is only serving a few thousand people at once, then you're fine!!
We love the fact that Erlang
uses "lighweight long-lived" processes,
which means we can connect millions of devices ...
For IoT Erlang is (unquestionably) the Answer!
For simpler web apps where you only expect a few users per day,
Rails/Django are still viable.
But why compromise if you don't have to?
Why settle for good when you can easily have/use the best?
Yes, GitHub is still using Rails for their Web App/Site.
But ask any of the core team at GitHub if
(given the chance to start over)
they would chose Rails
to build GitHub today,
and see how many of them say "yes, of course"
(with a straight face...)!
Also, GitHub does a lot of things to scale Rails in the background.
And many of their newer (client-side)
features are written in JavaScript!
see: /github
Bottom line is: anything can be made to scale using DevOps,
butPhoenixis made to scale bydefaultbecauseErlangwas invented solve scale!
"There are two kinds of programming languages - those that nobody uses and those that everybody's bitching about" ~ Bjarne Stroustrup (creator of
C++)
Go is very popular.
Largely due to the fact that Google "sponsors" it.
It was meant to simplify (replace) C++ and Java inside Google ...
and for the most part, it has succeeded!
We really like Go.
See:
dwyl/learn-go
Go was our "number two" choice when deciding
what programming language
(after Elixir) in our "post JS stack"...
The decision to use Elixir
instead of anything else was easy:
Elixiris functional (much simpler to read/write/maintain/extend)Elixirfunctions compose in a really elegant way as "plugs"/"pipelines"- Data is immutable which makes application state predictable (no guessing!)
- Types are dynamic and inferred (no need to manually declare them) but there are rules which simplify things and the compiler checks them giving an appropriate warning.
Erlangmakes distributed apps much easier and our plan is to build IoT systems that will mean connecting many (millions) devices with persistent connections,Erlangwas made for this!Phoenixincludes many useful things out-of-the box including several security features most people won't even think of.
Further Reading:
- Why
Gois Not Good: http://yager.io/programming/go.html GoWeb Frameworks: https://medium.com/code-zen/why-i-don-t-use-go-web-frameworks-1087e1facfa4- Why Everyone Hates
Go: https://npf.io/2014/10/why-everyone-hates-go/ (click-bait title, some valid points...) - Discussion: https://www.reddit.com/r/elixir/comments/3c8yfz/how_does_go_compare_to_elixir
(#HelpWanted expanding this answer...)
