Phoenix에서 Hello world!

4238 단어 ElixirPhoenix

Phoenix란?



Phoenix란 Elixir의 Web Application Framework입니다.
Rails 라이크한 MVC를 채용하고 있는 것 같다.

Elixir의 환경 구축은 다음과 같습니다.
Elixir에서 Hello world!

install Phoenix



기본적으로 공식 사이트 거리에 설치

install hex



Phoenix를 설치하려면 먼저 hex를 설치하십시오.

hex 란 패키지 매니저로, ruby ​​로 말하는 bundler 같은 것 같다.
$ mix local.hex

# Are you sure you want to install archive https://s3.amazonaws.com/s3.hex.pm/installs/1.0.0/hex.ez? [Yn]
y
# 2015-05-14 19:12:34 URL:https://s3.amazonaws.com/s3.hex.pm/installs/1.0.0/hex.ez [257739/257739] -> "/Users/tanaka/.mix/archives/hex.ez" [1]
# * creating /Users/tanaka/.mix/archives/hex.ez

위의 mix 명령은 빌드 도구? 그러면 다양한 작업을 수행할 수 있습니다.
ruby에서 말하는 rake 같은 것.

hex를 설치할 수 있었기 때문에 드디어 Phoenix 설치
$ mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v0.13.0/phoenix_new-0.13.0.ez

phoenix를 설치할 수 있었기 때문에 project를 new 해보십시오.
$ mix phoenix.new hello_phoenix

# * creating hello_phoenix/config/config.exs
# * creating hello_phoenix/config/dev.exs
# * creating hello_phoenix/config/prod.exs
# * creating hello_phoenix/config/prod.secret.exs
# * creating hello_phoenix/config/test.exs
# * creating hello_phoenix/lib/hello_phoenix.ex
# * creating hello_phoenix/lib/hello_phoenix/endpoint.ex
# * creating hello_phoenix/priv/static/robots.txt
# * creating hello_phoenix/test/controllers/page_controller_test.exs
# * creating hello_phoenix/test/views/error_view_test.exs
# * creating hello_phoenix/test/views/page_view_test.exs
# * creating hello_phoenix/test/support/conn_case.ex
# * creating hello_phoenix/test/test_helper.exs
# * creating hello_phoenix/web/controllers/page_controller.ex
# * creating hello_phoenix/web/templates/layout/application.html.eex
# * creating hello_phoenix/web/templates/page/index.html.eex
# * creating hello_phoenix/web/views/error_view.ex
# * creating hello_phoenix/web/views/layout_view.ex
# * creating hello_phoenix/web/views/page_view.ex
# * creating hello_phoenix/web/router.ex
# * creating hello_phoenix/web/web.ex
# * creating hello_phoenix/mix.exs
# * creating hello_phoenix/README.md
# * creating hello_phoenix/lib/hello_phoenix/repo.ex
# * creating hello_phoenix/test/support/model_case.ex
# * creating hello_phoenix/.gitignore
# * creating hello_phoenix/brunch-config.js
# * creating hello_phoenix/package.json
# * creating hello_phoenix/web/static/css/app.scss
# * creating hello_phoenix/web/static/js/app.js
# * creating hello_phoenix/web/static/vendor/phoenix.js
# * creating hello_phoenix/priv/static/images/phoenix.png
# 
# Install mix dependencies? [Yn]
y
# * running mix deps.get
# 
# Install brunch.io dependencies? [Yn]
y
# * running npm install
# 
# We are all set! Run your Phoenix application:
# 
#     $ cd hello_phoenix
#     $ mix phoenix.server
# 
# You can also run it inside IEx (Interactive Elixir) as:
# 
#     $ iex -S mix phoenix.server

중간에 종속 라이브러리 설치 권한이 필요하므로 y로 설치

설치할 수 있었기 때문에, 말했듯이 서버를 시작하십시오.
$ cd hello_phoenix
$ mix phoenix.server

# Could not find rebar, which is needed to build dependency :fs
# I can install a local copy which is just used by mix
# Shall I install rebar? [Yn]
y

또한 의존에 무언가 필요하고 설치할 수 있는지 물었으므로, y
poolboy라든지 cowboy라든지 넣기 시작했다
조사했을 때 cowboy라든지는 http server라든지의 라이브러리였다

종속 라이브러리 설치가 끝나면 서버가 시작됩니다.
[info] Running HelloPhoenix.Endpoint with Cowboy on port 4000 (http)
14 May 20:04:41 - info: compiled 3 files into 2 files in 1523ms

브라우저에서 다음에 액세스
http://localhost:4000



할 수 있었다!

좋은 웹페이지 즐겨찾기