11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Phoenix Frameworkをインストール

Posted at

Elixirの代表的なwebフレームワークであるPhoenix Frameworkをインストールする。

Phoenix Frameworkをインストール

$ mix local.hex
$ mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v0.13.1/phoenix_new-0.13.1.ez

プロジェクト作成

$ mix phoenix.new hello_phoenix
* creating hello_phoenix/config/config.exs
... いろいろ表示 ...
* creating hello_phoenix/priv/static/images/phoenix.png

Fetch and install dependencies? [Yn] Y

Phoenix uses an optional assets build tool called brunch.io
that requires node.js and npm. Installation instructions for
node.js, which includes npm, can be found at http://nodejs.org.

After npm is installed, install your brunch dependencies by
running inside your app:

    $ npm install

If you don't want brunch.io, you can re-run this generator
with the --no-brunch option.


We are all set! Run your Phoenix application:

    $ cd hello_phoenix
    $ mix deps.get
    $ mix phoenix.server

You can also run it inside IEx (Interactive Elixir) as:

    $ iex -S mix phoenix.server

サーバー起動

$ cd hello_phoenix
$ mix phoenix.server
==> fs (compile)
Compiled src/sys/inotifywait.erl
Compiled src/sys/fsevents.erl
Compiled src/sys/inotifywait_win32.erl

... いろいろ表示 ...

Compiled web/views/layout_view.ex
Generated hello_phoenix app
[info] Running HelloPhoenix.Endpoint with Cowboy on port 4000 (http)

module.js:340
    throw err;
          ^
Error: Cannot find module 'hello_phoenix/node_modules/brunch/bin/brunch'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

brunch.ioがないよと、起動時にエラーがでてしまう。

ブラウザでアクセスしたら、表示が変になってしまっている。

今回はphoenix frameworkを動かしてみたいだけなので、
プロジェクト作成時に以下のように表示された通り、--no-braunchをつけて、再度プロジェクトを作成する。

If you don't want brunch.io, you can re-run this generator
with the --no-brunch option.

再度プロジェクト作成

$ cd ..
$ rm -r hello_phoenix/
$ mix phoenix.new hello_phoenix --no-brunch

再度サーバー起動

$ cd hello_phoenix/
$ mix phoenix.server
==> fs (compile)
Compiled src/sys/inotifywait_win32.erl
... いろいろ ...
Compiled lib/hello_phoenix/endpoint.ex
Generated hello_phoenix app
[info] Running HelloPhoenix.Endpoint with Cowboy on port 4000 (http)

localhost:4000にアクセス

ターミナル上

[info] GET /
[info] Processing by HelloPhoenix.PageController.index/2
  Parameters: %{"format" => "html"}
  Pipelines: [:browser]
[info] Sent 200 in 7ms

ブラウザ表示

Kobito.npD51r.png

今度はちゃんと表示される。

11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?