Skip to content

Elixir Phoenix

 以下のコマンドで、Phoenixプロジェクトを作成します。

sh
mix phx.new web --no-ecto --no-mailer --no-dashboard --no-gettext

ディレクトリ構成

sh
.
`-- web
    |-- README.md
    |-- config
    |   |-- config.exs
    |   |-- dev.exs
    |   |-- prod.exs
    |   |-- runtime.exs
    |   `-- test.exs
    |-- lib
    |   |-- web
    |   |   `-- application.ex
    |   |-- web.ex
    |   |-- web_web
    |   |   |-- components
    |   |   |   |-- core_components.ex
    |   |   |   |-- layouts
    |   |   |   |   |-- app.html.heex
    |   |   |   |   `-- root.html.heex
    |   |   |   `-- layouts.ex
    |   |   |-- controllers
    |   |   |   |-- error_html.ex
    |   |   |   |-- error_json.ex
    |   |   |   |-- page_controller.ex
    |   |   |   |-- page_html
    |   |   |   |   `-- home.html.heex
    |   |   |   `-- page_html.ex
    |   |   |-- endpoint.ex
    |   |   |-- router.ex
    |   |   `-- telemetry.ex
    |   `-- web_web.ex
    |-- mix.exs
    |-- mix.lock
    `-- test
        |-- support
        |   `-- conn_case.ex
        |-- test_helper.exs
        `-- web_web
            `-- controllers
                |-- error_html_test.exs
                |-- error_json_test.exs
                `-- page_controller_test.exs

 以下のコマンドで、サーバーを起動します。

sh
cd web && mix phx.server

 ディレクトリ構成を変更する。

sh
.
|-- apps
|   `-- web
|       |-- README.md
|       |-- config
|       |   |-- config.exs
|       |   |-- dev.exs
|       |   |-- prod.exs
|       |   |-- runtime.exs
|       |   `-- test.exs
|       |-- lib
|       |   |-- application.ex
|       |   |-- components
|       |   |   |-- core_components.ex
|       |   |   |-- counter_component.ex
|       |   |   `-- layouts.ex
|       |   |-- endpoint.ex
|       |   |-- layouts
|       |   |   |-- app.html.heex
|       |   |   `-- root.html.heex
|       |   |-- pages
|       |   |   |-- counter_page.ex
|       |   |   `-- page_html.ex
|       |   |-- router.ex
|       |   `-- web.ex
|       `-- mix.exs
|-- mix.exs
`-- mix.lock