#語言系列# Elixir 初嘗試 0 --環境安裝

這一篇是從我本身的筆記裏面搬出來的,因此有些描述會過於簡潔。node

Elixir開始耍

最近無聊,逛ruby社區,發現一個詞貌似很火(原諒我最近沒讀書看報),好奇心又蹦出來了,就開始了學習elixir的道路。git

安裝elixir

安裝只需一行命令
brew install elixir
可是實際安裝的東西仔細觀察,會發現大概包含相關依賴jpeg, libtiff, wxmac, erlang
具體每一個作什麼的 請自行參考維基百科。github

➜  ~ 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

hello world 之旅

第二步是開始一個「hello world」之旅
但據說elixir的一個框架還不錯,名字也很厲害叫作phoenix,決定寫個簡單的API 來返回「hello world」吧
而後又開始安裝的道路。npm

官網介紹先須要利用mix命令(安裝完Elixir就會自動get到的一個命令)安裝Hex,Hex是個什麼東東,官網的介紹是The package manager for the Erlang ecosystem,簡單來講就是Erlang生態圈的包管理器,基本上就是npm之於node,gem之於ruby。api

➜  ~  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是否是都有了,就開始安裝鳳凰俠吧!ruby

➜  ~ 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。this

最後關於elixir這個語言的一些框架 第三方可用組件信息在github也有前人作了收集,叫作awesome-elixir.code

相關文章
相關標籤/搜索