Phoenix 初めてのプロジェクト作成

いきなりエラー。どうやら社内プロキシが邪魔して、社外のネットワークにつながらないらしい。

[bash]
$ mix local.hex
** (Mix) Could not access url https://s3.amazonaws.com/s3.hex.pm/installs/list.csv,
error: {:failed_connect, [{:to_address, {‘s3.amazonaws.com’, 443}},
{:inet, [:inet], :econnrefused}]}
[/bash]

ネットワークが繋がる環境で、気を取り直してもう一度。

[bash]
$ mix local.hex
[/bash]
すると、ホームディレクトリ下に .mix/archives/hex.ez というファイルがダウンロードされる。

[bash]
$ mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v0.13.1/phoenix_new-0.13.1.ez
[/bash]
すると、先程と同じディレクトリに .mix/archives/phoenix_new-0.13.1.ez というファイルがダウンロードされる。

そして、プロジェクトを作成。
[bash]
$ mix phoenix.new hello_phoenix –database mysql
[/bash]
※ここでプロジェクト名を HelloPhoenix としたら怒られた。命名規則があるのか調査中。

[bash]
$ mix phoenix.server
[error] Could not start watcher "node", executable does not exist
[/bash]

nodeがないと怒られるので、nodejsのサイトでダウンロード。

再度実行。

[bash]
$ 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/support/channel_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
[/bash]

[bash]
Fetch and install dependencies? [Yn] Y
* running npm install
* running mix deps.get

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

[/bash]

インストラクションに記述してあるように下記でサーバを起動する。

[bash]
$ cd hello_phoenix
$ mix phoenix.server
[/bash]

ブラウザを起動して、http://localhost:4000/ を開くと下記画面が表示される。

phoenix

This entry was posted in Elixir, Phoenix Framework, 技術情報. Bookmark the permalink.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です