Elixir 初尝试 0 --环境安装

这一篇是从我自己的笔记里面搬出来的,所以有些描述会过于简洁。

Elixir开始耍

最近无聊,逛ruby社区,发现一个词貌似很火(原谅我最近没读书看报),好奇心又蹦出来了,就开始了学习elixir的道路。

安装elixir

安装只需一行命令
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

hello world 之旅

第二步是开始一个“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.

你可能感兴趣的:(elixir)