スポンサーリンク

『Elixir/Phoenix 初級①』を写経する(3)

Windows8.1に、Vagrant+CentOS7.2で、Phoenix1.2.1の環境を構築した。

http://twosquirrel.mints.ne.jp/?p=14421

今回は、引き続き、以下の本の、第7,8,9章を写経していく。

写経といっても、個人的な好みで少し変更している箇所がある。

 

(環境)
Windows 8.1
VirtualBox 5.1.14
Vagrant 1.9.1
CentOS7.3
Erlang/OTP 19
Elixir 1.3.4
Phoenix 1.2.1
Postgresql 9.2.18
Node.js 6.9.5

(1)vagrant up したのち、TeraTermでログイン

phoenixアプリの作成

cd /vagrant

mix phoenix.new modest_greeter --no-ecto

image

image

いつもの

image

のエラーが出てくるので、いつも通り対処。

cd modest_greeter

npm install --no-bin-links
node node_modules/brunch/bin/brunch build

image

mix phoenix.server

image image

ホストOS(Windows8.1)で、http://localohost:4000

image

とりあえず、これで準備OK。

(2)ホストOS(Windows8.1)で、 VisualStudioCodeで、c:/vm/centos73_phoenix6/modest_greeter/ フォルダを開く。

image

●routerの設定 : web/router.ex の変更

image

●actionの作成 :  web/controllers/hello_controller.ex (新規作成)

image

●viewの作成 : web/views/hello_view.ex (新規作成)

image

●templateの作成 : web/templates/hello フォルダの作成
web/templates/hello/show.html.erx (新規作成)

image

●ブラウザで、http://localhost:4000/hello

image

(3)第8章

web/controllers/hello_controller.ex

image

web/templates/hello/show.html.erx

image

web/templates/layout/app.html.eex

image

http://localhost:4000/hello

image

(4)第9章

web/controllers/hello_controller.ex

image

image

web/router.ex

image

Ctrl+C を2回でサーバーを停止し、再度、mix phoenix.server

http://localhost:4000/hello/Bob

image

web/controllers/hello_controller.ex

image

http://localhost:4000/hello

image

スポンサーリンク