Elixir初試0--環境インストール

3736 ワード

この1編は自分のノートから出てきたので、簡潔すぎる記述もあります.
Elixirが遊び始める
最近退屈で、rubyコミュニティをぶらぶらして、1つの言叶がとても怒っているように见えて(私が最近本を読んでいないことを许して新闻を読む)、好奇心がまた飞び出して、elixirを学ぶ道を始めました.
elixirのインストール
インストールは1行のコマンドbrew install elixirですが、実際にインストールされているものをよく観察すると、jpeg、libtiff、wxmac、erlangに依存しているものが含まれていることがわかります.具体的には、ウィキペディアを参照してください.
➜  ~ brew install elixir
==> Installing dependencies for elixir: jpeg, libtiff, wxmac, erlang
==> Installing elixir dependency: jpeg
==> Downloading https://homebrew.bintray.com/bottles/jpeg-8d.el_capitan.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring jpeg-8d.el_capitan.bottle.2.tar.gz
?  /usr/local/Cellar/jpeg/8d: 19 files, 713.7K
==> Installing elixir dependency: libtiff
==> Downloading https://homebrew.bintray.com/bottles/libtiff-4.0.6_1.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libtiff-4.0.6_1.el_capitan.bottle.tar.gz
?  /usr/local/Cellar/libtiff/4.0.6_1: 261 files, 3.4M
==> Installing elixir dependency: wxmac
==> Downloading https://homebrew.bintray.com/bottles/wxmac-3.0.2_2.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring wxmac-3.0.2_2.el_capitan.bottle.tar.gz
?  /usr/local/Cellar/wxmac/3.0.2_2: 809 files, 23.7M
==> Installing elixir dependency: erlang
==> Downloading https://homebrew.bintray.com/bottles/erlang-18.3.el_capitan.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring erlang-18.3.el_capitan.bottle.2.tar.gz
==> Caveats
Man pages can be found in:
  /usr/local/opt/erlang/lib/erlang/man
 
Access them with `erl -man`, or add this directory to MANPATH.
==> Summary
?  /usr/local/Cellar/erlang/18.3: 7,388 files, 272.9M
==> Installing elixir
==> Downloading https://homebrew.bintray.com/bottles/elixir-1.3.1.el_capitan.bottle.tar.gz
 
######################################################################## 100.0%
==> Pouring elixir-1.3.1.el_capitan.bottle.tar.gz
?  /usr/local/Cellar/elixir/1.3.1: 383 files, 5M

ハローワールドの旅
第2歩は「hello world」の旅を始めることですが、elixirのフレームワークは悪くないそうで、名前もすごいphoenixというので、簡単なAPIを書いて「hello world」に戻ることにしましょう.そしてまた取り付けの道を始めることにしました.
まずmixコマンド(Elixirをインストールすると自動的にgetされるコマンド)を利用してHexをインストールする必要があります.Hexは何ですか.公式サイトの紹介はThe package manager for the Erlang ecosystemです.簡単に言えばErlang生態圏のパッケージマネージャです.基本的にはnpmのnode、gemのrubyです.
➜  ~  mix local.hex
Are you sure you want to install archive "https://repo.hex.pm/installs/1.3.0/hex-0.14.1.ez"? [Yn] y
* creating .mix/archives/hex-0.14.1

Phoenix
これではまだ始まらないので、Elixir and Erlangがあるかどうかをチェックして、鳳凰侠のインストールを始めましょう.
➜  ~ mix archive.install https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez
Are you sure you want to install archive "https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez"? [Yn] y
* creating .mix/archives/phoenix_new

インストールに失敗した場合は、公式サイトの次のパッケージをファイルシステムに置いてrunでコマンドを実行します.
mix archive.install /path/to/local/phoenix_new.ez

私もできるはずですが、公式サイトでは次のように言っています.
Note: if the Phoenix archive won't install properly with this command, we can download the package from the Phoenix archives, save it to the filesystem, and then run: mix archive.install /path/to/local/phoenix_new.ez.

このコマンドは、Plug,Cowboy,and Ectoなどの多くのデフォルトパッケージをインストールし、brunchを使用する必要がある場合も同様です.ioはいくつかの静的部分をコンパイルするためにnpmを使用する必要があり、npmはデフォルトでnodeを必要とします.
最後にelixirという言語のいくつかのフレームワークについて第三者が利用できるコンポーネント情報はgithubでもawesome-elixirという先人が収集した.