LoginSignup
30
29

More than 5 years have passed since last update.

Phoenix Framework(v0.8) 概要

Posted at

http://www.phoenixframework.org/v0.8.0/docs/overview を翻訳しました.
翻訳の誤りなどあればご指摘お待ちしております.


Phoenix is a web development framework written in Elixir which implements the server-side MVC pattern. If you've ever used a similar framework, say Ruby on Rails or Python's Django, many of the concepts will be familiar to you. Phoenix is not, however, simply a Rails clone. It aims to have the best of both worlds, high developer productivity and high application performance. Phoenix also has some interesting new twists, channels for managing Websockets, pre-compiled templates and the potential for alternative architectures which may make services more manageable from the very beginning of your project.

Phoenix は Elixir で書かれた,サーバーサイド MVC パターンで実装した Web 開発フレームワークです.
もし Ruby on Rails や Python の Django といった,これと似ているフレームワークを使ったことがあれば,多くのコンセプトはあなたに馴染みのあるものでしょう.
Phoenix はしかし,単なる Rails のクローンではありません.
高い生産性と高いアプリケーションパフォーマンス,両方の長所を持っていることを目指しています.
Phoenix はいくつか面白い特徴を持っています.Websockets を管理するための channnel,プリコンパイルされたテンプレート,プロジェクト当初からサービスを作りやすく,管理しやすくなる,既存のアーキテクチャの代替となる可能性を秘めています.

If you are already familiar with Elixir, great! If not, there are a number of places you can go to learn. You might want to read through the Elixir guides first. You might also want to look through any of the books, blogs or videos listed in the Resources Guide.

もし既に Elixir に慣れているなら,すばらしいことです!
もしそうではないなら,学べる場所がいくつかあります.
最初に Elixir guides を通して読むことをおすすめします.
また,Resources Guide に記載されている書籍,ブログ,ビデオのいずれかに目を通すとよいでしょう.

The aim of this introductory guide is to present a brief, high level overview of Phoenix, the parts that make it up, and the layers underneath that support it.

この入門ガイドでは,Phoenix の大まかな概要と,それを構成するための部品,階層を簡潔に示します.

Phoenix is actually the top layer of a multi-layer system designed to be modular and flexible. The other layers are the Elixir middleware project, Plug, and the Erlang web server, Cowboy. Plug and Cowboy are covered in the next sections of this guide.

実際のところ Phoenix はモジュール化と柔軟性の向上を目的にデザインされた複数の階層の上になりたっています.
Phoenix と別の階層とは Elixir のミドルウェアプロジェクトである Plug,Erlang のウェブサーバーである Cowboy です.
Plug と Cowboy についてはこのガイドの次のセクションで説明します.

Phoenix is made up of a number of distinct parts, each with its own purpose and role to play in building a web application. We will cover them all in depth throughout these guides, but here's a quick breakdown.

Phoenix は,個々の目的を持った独立した部品で構成されており,それぞれが web アプリケーションの構築の中で役割をはたすことで組みあげられています.
それぞれについては後ほどこのガイドで掘り下げますが,ここでは簡単に分類してみましょう.

The Router

  • parses incoming requests and dispatches to the correct controller/action, passing parameters as needed
  • provides helpers to generate route paths or urls to resources

The Router

  • 来るリクエストをパースして,正しいコントローラー/アクションへと送ります.必要なパラメーターも渡します
  • パスや url をリソースへとルーティングするためのヘルパーを提供します

The Endpoint

  • handles all aspects of requests up until the beginning of our applications

The Endpoint

  • アプリケーションを開始するまでに,全てのリクエストにおいて興味のある部分を扱います

Controllers

  • provide functions called actions to handle requests
  • Actions
    • prepare data and pass it into views
    • invoke rendering via views
    • perform redirects

Controllers

  • リクエストを扱うためにアクションから呼ばれる関数を提供します
  • Actions
    • データを用意して View に渡します
    • view を通してレンダリングします
    • リダイレクトを実行します

Views

  • render templates
  • define helper functions, available in templates, to decorate raw data

Views

  • テンプレートをレンダリングします
  • 生のデータを見やすくするため,テンプレート内で使えるヘルパー関数を定義します

Templates

  • are what they sound like :)

Templates

  • 名は体を表します :)

Channels

  • manage sockets
  • are roughly analogous to controllers except that they are bi-directional and persistent

Channels

  • socket を管理します
  • 双方向通信ができて,ずっと繋っている.ということを除けばコントローラーと似ています

Sockets

  • are multiplexed, persistent connections

Sockets

  • とは,多重化された持続的な接続のことです

Topics

  • serve as a PubSub broadcast layer

Topics

  • PubSub ブロードキャスト層を提供します

Plug

Plug is Elixir's middleware layer. Conceptually, it shares a lot with other middleware layers like Rack for Ruby or WSGI for Python. Plugs are reusable modules that share the same very small, very regular public api. They provide discreet behaviors - like request header parsing or logging. Because the Plug api is so consistent, they can be stacked and executed in a set order, like a pipeline. They can also be re-used within a project or across projects.

Plug は Elixir のミドルウェア層です.概念としては,Ruby の Rack,Python の WSGI のようなミドルウェアと共通しています.
Plugs はとても小さく,とても一般的な公開APIをもった再利用可能なモジュールです.
それらは控えめな振舞いを提供します - 例えばリクエストヘッダーをパースしたり,ログを取るといったことです.
ですから,Plug の API はとても安定しています.それらはスタックに積み上げられ,パイプラインのように順番に実行されます.
それらはプロジェクト内やプロジェクトにまたがって再利用できます.

Plugs can be written to handle almost anything, from authentication to parameter pre-processing, and even rendering.

Plugs は認証,パラメーターの前処理,レンダリングでさえも,ほとんど全てのことを扱えるように書かれています.

Phoenix takes great advantage of Plug in general - the router and controllers especially so.

Phoenix は Plug に備わっているそのすばらしい利点を得ています - router と controllers では特にそうです.

One of the most important things about Plug, is that it provides adapters to HTTP servers which will ultimately deliver application content to your users. Currently, Plug only provides an adapter to Cowboy, which we will talk about next, but there are plans to provide adapters for other servers in the future.

Plug で最も大事なことの一つに,アプリケーションの内容を最終的にユーザーへと届けるための HTTP サーバーのアダプターを提供していることがあります.
現在,Plug は Cowboy へのアダプターのみを提供しています.今後への話をすると,他のサーバーへのアダプターを提供する予定があります.

Links to more in-depth information on Plug can be found in the Resources Guide.

Plug のもっと詳しい情報へのリンクは Resources Guide にあります.

Cowboy

Cowboy is an HTTP server written in Erlang by Loïc Hoguin of 99s. Cowboy is built in a modular way on top of Ranch, Bullet, and Sheriff. This is how 99s describes them.

Cowboy は 99s の Loïc Hoguin によって Erlang で書かれて HTTP サーバーです.
Cowboy は 組立式で Ranch, Bullet, Sheriff といったものの上に構築されています.
以下は 99s が書いたそれぞれの特徴です.

  • Cowboy is a small, fast, modular HTTP server supporting Websockets, SPDY and more.
  • Ranch is a socket acceptor pool for TCP protocols. It is also a standalone library for building networked applications.
  • Bullet is a simple, reliable, efficient streaming library.
  • Sheriff uses parse transforms for type based validation. Sheriff also validates data dynamically using Erlang's type system with no extra code required.
  • Cowboy は小さく,速く,組立式の HTTP サーバーで Websockets や SPDY などをサポートしています.
  • Ranch は TCP プロトコルのためのソケット受け入れプールです.これはネットワークを使うアプリケーションを構築するための独立したライブラリにもなっています.
  • Bullet は簡潔で,信頼性の高い,効果的なストリーミングライブラリです
  • Sheriff は型ベースのバリデーションのために parse transform を使います.Sheriff は外部の追加コードを必要とせずに Erlang の型システムを使って動的にデータをバリデーションします.

Cowboy has fantastic documentation. The Guides are especially helpful. Learning more about Cowboy will surely help you to understand Phoenix more fully.

Cowboy には素晴しいドキュメントがあります.特に Guides がためになります.
Cowboy について学ぶことはきっと Phoenix をもっと知るための助けになるでしょう.

Cowboy has its own section of links in the Resources Guide.

Resources Guide の中に Cowboy へのリンクがあります.

30
29
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
30
29