# Phoenix Framework — Productive Web Framework for Elixir > Phoenix is a web framework for Elixir that provides peace of mind from prototype to production. Channels for real-time communication, LiveView for server-rendered reactive UI, and the fault-tolerance of the BEAM VM. Built for apps that need to scale. ## Install Save as a script file and run: ## Quick Use ```bash mix archive.install hex phx_new mix phx.new my_app --database postgres cd my_app mix setup mix phx.server # Visit http://localhost:4000 ``` ```elixir # lib/my_app_web/router.ex scope "/api", MyAppWeb do pipe_through :api resources "/assets", AssetController, only: [:index, :create] end # lib/my_app_web/controllers/asset_controller.ex defmodule MyAppWeb.AssetController do use MyAppWeb, :controller def index(conn, _params) do assets = Repo.all(Asset) json(conn, %{assets: assets}) end end ``` ## Intro Phoenix is the premier web framework for Elixir, created by Chris McCord. It provides peace of mind from prototype to production: Channels for real-time communication, LiveView for server-rendered reactive UIs (no JavaScript needed), and the fault-tolerance of the BEAM virtual machine. Phoenix consistently handles millions of concurrent WebSocket connections per server. - **Repo**: https://github.com/phoenixframework/phoenix - **Stars**: 22K+ - **Language**: Elixir - **License**: MIT ## What Phoenix Does - **MVC** — controllers, views, templates - **Channels** — real-time WebSocket communication - **LiveView** — server-rendered reactive UI (no JS framework needed) - **Ecto** — database query DSL and migrations - **PubSub** — distributed pub/sub - **Presence** — track connected users - **Telemetry** — instrumentation hooks - **mix phx.gen** — generators for context, schema, HTML, JSON ## Comparison | Framework | Concurrency | Real-time | |---|---|---| | Phoenix | BEAM processes | Channels + LiveView | | Rails | Threads | ActionCable | | Django | WSGI + Channels | Django Channels | | Next.js | Node.js | WebSocket via lib | ## 常见问题 FAQ **Q: LiveView 能替代 React?** A: 对中高交互性应用可以。LiveView 通过 WebSocket 推送 HTML diff 到浏览器,延迟在 50ms 以内感知很好。超复杂前端交互还是建议 React/Vue + Phoenix API。 ## 来源与致谢 Sources - Docs: https://hexdocs.pm/phoenix - GitHub: https://github.com/phoenixframework/phoenix - License: MIT --- Source: https://tokrepo.com/en/workflows/412ffb02-3634-11f1-9bc6-00163e2b0d79 Author: Script Depot