Skip to content

Instantly share code, notes, and snippets.

@bingoabs
Forked from chrismccord/upgrade.md
Created July 28, 2017 02:23
Show Gist options
  • Save bingoabs/b70029f77d75a02212c7cdd07320a8c5 to your computer and use it in GitHub Desktop.
Save bingoabs/b70029f77d75a02212c7cdd07320a8c5 to your computer and use it in GitHub Desktop.

Revisions

  1. @chrismccord chrismccord revised this gist Jul 25, 2017. 1 changed file with 43 additions and 42 deletions.
    85 changes: 43 additions & 42 deletions upgrade.md
    Original file line number Diff line number Diff line change
    @@ -43,23 +43,24 @@ In `mix.exs`, update your `elixirc_paths/1` clauses to remove "web":

    If you have a `reloadable_paths` configuration in your `config/dev.exs`, you may remove this value as all `elixirc_paths` are now reloaded in dev by default.

    ### Move your root-level `web/` directory to `lib/app_name/web`, and migrate to new `Web` namespace
    ### Move your root-level `web/` directory to `lib/app_name_web`, and migrate to new `Web` namespace

    The root level `web/` directory for new projects has been removed in favor of `lib/my_app/web`. Additionally, a `Web` namespace convention has been added to isolate the web interface from your elixir application.
    The root level `web/` directory for new projects has been removed in favor of `lib/my_app_web`. Additionally, a `Web` namespace convention has been added to isolate the web interface from your elixir application.

    Migrate your files to the new structure with the following steps:

    1. `$ cd my_app`
    2. `$ mv web lib/my_app/web`
    3. `$ mv lib/my_app/endpoint.ex lib/my_app/web/`
    4. Update your view root path in `web.ex` to point to the new template location, and add the `:namespace` option:
    2. `$ mv web/web.ex lib/my_app_web.ex`
    2. `$ mv web lib/my_app_web`
    3. `$ mv lib/my_app/endpoint.ex lib/my_app_web/`
    4. Update your view root path in `lib/my_app_web.ex` to point to the new template location, and add the `:namespace` option:

    ```diff
    def view do
    quote do
    - use Phoenix.View, root: "web/templates"
    + use Phoenix.View, root: "lib/my_app/web/templates",
    + namespace: MyApp.Web
    + use Phoenix.View, root: "lib/my_app_web/templates",
    + namespace: MyAppWeb
    ...
    ```

    @@ -69,7 +70,7 @@ Migrate your files to the new structure with the following steps:
    def controller do
    quote do
    - use Phoenix.Controller
    + use Phoenix.Controller, namespace: MyApp.Web
    + use Phoenix.Controller, namespace: MyAppWeb
    ```


    @@ -80,51 +81,51 @@ Migrate your files to the new structure with the following steps:
    quote do
    ...
    - import MyApp.Router.Helpers
    + import MyApp.Web.Router.Helpers
    + import MyAppWeb.Router.Helpers
    - import MyApp.Gettext
    + import MyApp.Web.Gettext
    + import MyAppWeb.Gettext
    end
    end

    def view do
    quote do
    ...
    - import MyApp.Router.Helpers
    + import MyApp.Web.Router.Helpers
    + import MyAppWeb.Router.Helpers
    - import MyApp.ErrorHelpers
    + import MyApp.WebErrorHelpers
    + import MyAppWebErrorHelpers
    - import MyApp.Gettext
    + import MyApp.Web.Gettext
    + import MyAppWeb.Gettext
    end
    end

    def channel do
    quote do
    ...
    - import MyApp.Gettext
    + import MyApp.Web.Gettext
    + import MyAppWeb.Gettext
    end
    end
    ```


    6. Rename all web related modules in `lib/my_app/web/` (`gettext.ex`, `controllers/*`, `views/*`, `channels/*`, `endpoint.ex`, `router.ex`) to include a `Web` namespace, for example:
    6. Rename all web related modules in `lib/my_app_web/` (`gettext.ex`, `controllers/*`, `views/*`, `channels/*`, `endpoint.ex`, `router.ex`) to include a `Web` namespace, for example:

    * `MyApp.Endpoint` => `MyApp.Web.Endpoint`
    * `MyApp.Router` => `MyApp.Web.Router`
    * `MyApp.PageController` => `MyApp.Web.PageController`
    * `MyApp.PageView` => `MyApp.Web.PageView`
    * `MyApp.UserSocket` => `MyApp.Web.UserSocket`
    * `MyApp.Endpoint` => `MyAppWeb.Endpoint`
    * `MyApp.Router` => `MyAppWeb.Router`
    * `MyApp.PageController` => `MyAppWeb.PageController`
    * `MyApp.PageView` => `MyAppWeb.PageView`
    * `MyApp.UserSocket` => `MyAppWeb.UserSocket`
    * etc

    7. Update all alias in `lib/app_name/web/router.ex` to include new `Web` namespace. Most likely you can accomplish this by adding `.Web` to the second argument of your scope blocks, for example:
    7. Update all alias in `lib/app_name_web/router.ex` to include new `Web` namespace. Most likely you can accomplish this by adding `Web` to the second argument of your scope blocks, for example:

    ```diff
    - defmodule MyApp.Router do
    + defmodule MyApp.Web.Router do
    + defmodule MyAppWeb.Router do
    ...
    - scope "/", MyApp do
    + scope "/", MyApp.Web do
    + scope "/", MyAppWeb do
    pipe_through :browser

    resources "/users", UserController
    @@ -136,13 +137,13 @@ Migrate your files to the new structure with the following steps:

    ```diff
    - defmodule MyApp.Endpoint do
    + defmodule MyApp.Web.Endpoint do
    + defmodule MyAppWeb.Endpoint do
    ...
    - socket "/socket", MyApp.UserSocket
    + socket "/socket", MyApp.Web.UserSocket
    + socket "/socket", MyAppWeb.UserSocket
    ...
    - plug MyApp.Router
    + plug MyApp.Web.Router
    + plug MyAppWeb.Router
    ```

    8. in `lib/my_app.ex`, update your children to reference the new endpoint and remove the config_change callback:
    @@ -152,7 +153,7 @@ Migrate your files to the new structure with the following steps:
    children = [
    ...
    - supervisor(MyApp.Endpoint, []),
    + supervisor(MyApp.Web.Endpoint, []),
    + supervisor(MyAppWeb.Endpoint, []),
    ...
    ]

    @@ -167,26 +168,26 @@ Migrate your files to the new structure with the following steps:

    ```diff
    - config :my_app, MyApp.Endpoint,
    + config :my_app, MyApp.Web.Endpoint,
    + config :my_app, MyAppWeb.Endpoint,
    ...
    - render_errors: [view: MyApp.ErrorView, accepts: ~w(html json)],
    + render_errors: [view: MyApp.Web.ErrorView, accepts: ~w(html json)],
    + render_errors: [view: MyAppWeb.ErrorView, accepts: ~w(html json)],
    ...
    ```

    9. Update your live-reload patterns config in `config/dev.exs`:

    ```diff
    - config :my_app, MyApp.Endpoint,
    + config :my_app, MyApp.Web.Endpoint,
    + config :my_app, MyAppWeb.Endpoint,
    live_reload: [
    patterns: [
    ~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
    ~r{priv/gettext/.*(po)$},
    - ~r{web/views/.*(ex)$},
    - ~r{web/templates/.*(eex)$}
    + ~r{lib/my_app/web/views/.*(ex)$},
    + ~r{lib/my_app/web/templates/.*(eex)$}
    + ~r{lib/my_app_web/views/.*(ex)$},
    + ~r{lib/my_app_web/templates/.*(eex)$}
    ]
    ]
    ```
    @@ -195,35 +196,35 @@ Migrate your files to the new structure with the following steps:

    ```diff
    -defmodule MyApp.ConnCase do
    +defmodule MyApp.Web.ConnCase do
    +defmodule MyAppWeb.ConnCase do
    using do
    quote do
    ...
    - import MyApp.Router.Helpers
    + import MyApp.Web.Router.Helpers
    + import MyAppWeb.Router.Helpers

    # The default endpoint for testing
    - @endpoint MyApp.Endpoint
    + @endpoint MyApp.Web.Endpoint
    + @endpoint MyAppWeb.Endpoint
    end
    end
    ...


    -defmodule MyApp.ChannelCase do
    +defmodule MyApp.Web.ChannelCase do
    +defmodule MyAppWeb.ChannelCase do

    using do
    quote do
    ...
    - @endpoint MyApp.Endpoint
    + @endpoint MyApp.Web.Endpoint
    + @endpoint MyAppWeb.Endpoint
    end
    end
    ...
    ```

    11. Update all `test/*/**.exs` references to `use MyApp.ConnCase` or `use MyApp.ChannelCase` to use new `MyApp.Web.ConnCase` and `MyApp.Web.ChannelCase` aliases.
    11. Update all `test/*/**.exs` references to `use MyApp.ConnCase` or `use MyApp.ChannelCase` to use new `MyAppWeb.ConnCase` and `MyAppWeb.ChannelCase` aliases.

    ### Move static assets inside self-contained assets/ directory

    @@ -232,7 +233,7 @@ New projects now include a root-level `assets/` directory, which serves as a sel
    1) move all `web/static/` sources into `assets/`, followed by `package.json`, `node_modules`, and `brunch-config.js`

    ```console
    $ mv mv lib/my_app/web/static assets/
    $ mv mv lib/my_app_web/static assets/
    $ mv assets/assets assets/static
    $ mv package.json assets/
    $ mv brunch-config.js assets/
    @@ -297,7 +298,7 @@ New projects now include a root-level `assets/` directory, which serves as a sel
    4) Update your `config/dev.exs` watcher to run in the new assets directory:

    ```diff
    config :my_app, MyApp.Web.Endpoint,
    config :my_app, MyAppWeb.Endpoint,
    ...
    watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin",
    - cd: Path.expand("../", __DIR__)]]
    @@ -313,6 +314,6 @@ Test it all with `mix phx.server`, and `mix test` and you should see:

    ```
    $ mix phx.server
    [info] Running MyApp.Web.Endpoint with Cowboy using http://0.0.0.0:4000
    [info] Running MyAppWeb.Endpoint with Cowboy using http://0.0.0.0:4000
    01 Mar 15:40:05 - info: compiled 6 files into 2 files, copied 3 in 976ms
    ```
    ```
  2. @chrismccord chrismccord revised this gist Apr 7, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion upgrade.md
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ end
    If using the digest task (mix phoenix.digest), the location of the built manifest has changed from `priv/static/manifest.json` to `priv/static/cache_manifest.json`. Update your `config/prod.exs` endpoint config with the following changes:

    ```diff
    -cache_static_manifest: "priv/static/cache_manifest.json"
    -cache_static_manifest: "priv/static/manifest.json"
    +cache_static_manifest: "priv/static/cache_manifest.json"
    ```

  3. @chrismccord chrismccord revised this gist Mar 13, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion upgrade.md
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ end

    ## Update your static manifest location

    If using the digest task (mix phoenix.digest), the location of the built manifest has changed from `priv/static/manifest.json` to `priv/static/cache_manifest.json`. Update your `config/*.exs` endpoint config with the following changes:
    If using the digest task (mix phoenix.digest), the location of the built manifest has changed from `priv/static/manifest.json` to `priv/static/cache_manifest.json`. Update your `config/prod.exs` endpoint config with the following changes:

    ```diff
    -cache_static_manifest: "priv/static/cache_manifest.json"
  4. @chrismccord chrismccord revised this gist Mar 13, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion upgrade.md
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ end

    ## Update your static manifest location

    If using the digest task, the location of the built manifest has changed from `priv/static/manifest.json` to `priv/static/cache_manifest.json`:
    If using the digest task (mix phoenix.digest), the location of the built manifest has changed from `priv/static/manifest.json` to `priv/static/cache_manifest.json`. Update your `config/*.exs` endpoint config with the following changes:

    ```diff
    -cache_static_manifest: "priv/static/cache_manifest.json"
  5. @chrismccord chrismccord revised this gist Mar 13, 2017. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions upgrade.md
    Original file line number Diff line number Diff line change
    @@ -16,6 +16,15 @@ def deps do
    end
    ```

    ## Update your static manifest location

    If using the digest task, the location of the built manifest has changed from `priv/static/manifest.json` to `priv/static/cache_manifest.json`:

    ```diff
    -cache_static_manifest: "priv/static/cache_manifest.json"
    +cache_static_manifest: "priv/static/cache_manifest.json"
    ```

    Next, run `mix deps.get` and you're all set! Continue reading to jump on the latest project structure conventions (optional).


  6. @chrismccord chrismccord revised this gist Mar 2, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions upgrade.md
    Original file line number Diff line number Diff line change
    @@ -16,6 +16,8 @@ def deps do
    end
    ```

    Next, run `mix deps.get` and you're all set! Continue reading to jump on the latest project structure conventions (optional).


    ## Update your project the new 1.3 directory structure (optional)

  7. @chrismccord chrismccord revised this gist Mar 2, 2017. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion upgrade.md
    Original file line number Diff line number Diff line change
    @@ -40,7 +40,8 @@ Migrate your files to the new structure with the following steps:

    1. `$ cd my_app`
    2. `$ mv web lib/my_app/web`
    3. Update your view root path in `web.ex` to point to the new template location, and add the `:namespace` option:
    3. `$ mv lib/my_app/endpoint.ex lib/my_app/web/`
    4. Update your view root path in `web.ex` to point to the new template location, and add the `:namespace` option:

    ```diff
    def view do
  8. @chrismccord chrismccord revised this gist Mar 2, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion upgrade.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ If you want a run-down of the 1.3 changes and the design decisions behidn those

    To use the new `phx.new` project generator, you can install the archive with the following command:

    $ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez
    $ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez



  9. @chrismccord chrismccord revised this gist Mar 2, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions upgrade.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,11 @@
    If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8

    To use the new `phx.new` project generator, you can install the archive with the following command:

    $ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez



    ## Bump your phoenix dep
    Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in `mix.exs`:

  10. @chrismccord chrismccord revised this gist Mar 1, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions upgrade.md
    Original file line number Diff line number Diff line change
    @@ -159,8 +159,8 @@ Migrate your files to the new structure with the following steps:
    9. Update your live-reload patterns config in `config/dev.exs`:

    ```diff
    - config :demo, MyApp.Endpoint,
    + config :demo, MyApp.Web.Endpoint,
    - config :my_app, MyApp.Endpoint,
    + config :my_app, MyApp.Web.Endpoint,
    live_reload: [
    patterns: [
    ~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
  11. @chrismccord chrismccord revised this gist Mar 1, 2017. 1 changed file with 15 additions and 16 deletions.
    31 changes: 15 additions & 16 deletions upgrade.md
    Original file line number Diff line number Diff line change
    @@ -71,20 +71,20 @@ Migrate your files to the new structure with the following steps:
    def view do
    quote do
    ...
    - import Demo.Router.Helpers
    + import Demo.Web.Router.Helpers
    - import Demo.ErrorHelpers
    + import Demo.WebErrorHelpers
    - import Demo.Gettext
    + import Demo.Web.Gettext
    - import MyApp.Router.Helpers
    + import MyApp.Web.Router.Helpers
    - import MyApp.ErrorHelpers
    + import MyApp.WebErrorHelpers
    - import MyApp.Gettext
    + import MyApp.Web.Gettext
    end
    end

    def channel do
    quote do
    ...
    - import Demo.Gettext
    + import Demo.Web.Gettext
    - import MyApp.Gettext
    + import MyApp.Web.Gettext
    end
    end
    ```
    @@ -120,11 +120,11 @@ Migrate your files to the new structure with the following steps:
    - defmodule MyApp.Endpoint do
    + defmodule MyApp.Web.Endpoint do
    ...
    - socket "/socket", Demo.UserSocket
    + socket "/socket", Demo.Web.UserSocket
    - socket "/socket", MyApp.UserSocket
    + socket "/socket", MyApp.Web.UserSocket
    ...
    - plug Demo.Router
    + plug Demo.Web.Router
    - plug MyApp.Router
    + plug MyApp.Web.Router
    ```

    8. in `lib/my_app.ex`, update your children to reference the new endpoint and remove the config_change callback:
    @@ -133,15 +133,14 @@ Migrate your files to the new structure with the following steps:
    ...
    children = [
    ...
    - supervisor(Demo.Endpoint, []),
    + supervisor(Demo.Web.Endpoint, []),
    - supervisor(MyApp.Endpoint, []),
    + supervisor(MyApp.Web.Endpoint, []),
    ...
    ]

    ...
    - def config_change(changed, _new, removed) do
    - Demo.Endpoint.config_change(changed, removed)
    - Demo.Web..Endpoint.config_change(changed, removed)
    - MyApp.Endpoint.config_change(changed, removed)
    - :ok
    - end
    ```
  12. @chrismccord chrismccord revised this gist Mar 1, 2017. 1 changed file with 11 additions and 12 deletions.
    23 changes: 11 additions & 12 deletions upgrade.md
    Original file line number Diff line number Diff line change
    @@ -61,10 +61,10 @@ Migrate your files to the new structure with the following steps:
    def controller do
    quote do
    ...
    - import Demo.Web.Router.Helpers
    + import Demo.Router.Helpers
    - import Demo.Gettext
    + import Demo.Web.Gettext
    - import MyApp.Router.Helpers
    + import MyApp.Web.Router.Helpers
    - import MyApp.Gettext
    + import MyApp.Web.Gettext
    end
    end

    @@ -90,7 +90,7 @@ Migrate your files to the new structure with the following steps:
    ```


    6. Rename all web related modules in `lib/my_app/web/` (gettext.ex, controllers/*, views/*, channels/*, endpoint.ex, router.ex) to include a `Web` namespace, for example:
    6. Rename all web related modules in `lib/my_app/web/` (`gettext.ex`, `controllers/*`, `views/*`, `channels/*`, `endpoint.ex`, `router.ex`) to include a `Web` namespace, for example:

    * `MyApp.Endpoint` => `MyApp.Web.Endpoint`
    * `MyApp.Router` => `MyApp.Web.Router`
    @@ -127,7 +127,7 @@ Migrate your files to the new structure with the following steps:
    + plug Demo.Web.Router
    ```

    8. in `lib/my_app.ex`, update your children and config_change callback to reference the new endpoint:
    8. in `lib/my_app.ex`, update your children to reference the new endpoint and remove the config_change callback:

    ```diff
    ...
    @@ -139,15 +139,14 @@ Migrate your files to the new structure with the following steps:
    ]

    ...
    def config_change(changed, _new, removed) do
    - def config_change(changed, _new, removed) do
    - Demo.Endpoint.config_change(changed, removed)
    + Demo.Web..Endpoint.config_change(changed, removed)
    :ok
    end

    - Demo.Web..Endpoint.config_change(changed, removed)
    - :ok
    - end
    ```

    8. Update all endpoint aliases in config/*.exs (config.exs, prod.exs, prod.secret.exs dev.exs, test.exs ], etc) aliases to use new `Web` namespace:
    8. Update all endpoint aliases in config/*.exs (config.exs, prod.exs, prod.secret.exs dev.exs, test.exs, etc) aliases to use new `Web` namespace:

    ```diff
    - config :my_app, MyApp.Endpoint,
  13. @chrismccord chrismccord created this gist Mar 1, 2017.
    302 changes: 302 additions & 0 deletions upgrade.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,302 @@
    If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8

    ## Bump your phoenix dep
    Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in `mix.exs`:

    ```elixir
    def deps do
    [{:phoenix, "~> 1.3.0-rc"},
    ...]
    end
    ```


    ## Update your project the new 1.3 directory structure (optional)

    ### mix.exs

    In `mix.exs`, update your `elixirc_paths/1` clauses to remove "web":

    ```diff
    - defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
    - defp elixirc_paths(_), do: ["lib", "web"]
    + defp elixirc_paths(:test), do: ["lib", "test/support"]
    + defp elixirc_paths(_), do: ["lib"]
    ```

    If you have a `reloadable_paths` configuration in your `config/dev.exs`, you may remove this value as all `elixirc_paths` are now reloaded in dev by default.

    ### Move your root-level `web/` directory to `lib/app_name/web`, and migrate to new `Web` namespace

    The root level `web/` directory for new projects has been removed in favor of `lib/my_app/web`. Additionally, a `Web` namespace convention has been added to isolate the web interface from your elixir application.

    Migrate your files to the new structure with the following steps:

    1. `$ cd my_app`
    2. `$ mv web lib/my_app/web`
    3. Update your view root path in `web.ex` to point to the new template location, and add the `:namespace` option:

    ```diff
    def view do
    quote do
    - use Phoenix.View, root: "web/templates"
    + use Phoenix.View, root: "lib/my_app/web/templates",
    + namespace: MyApp.Web
    ...
    ```

    4. Add the namespace option to your `controller` definition in `web.ex`:

    ```diff
    def controller do
    quote do
    - use Phoenix.Controller
    + use Phoenix.Controller, namespace: MyApp.Web
    ```


    5. Update your aliases in web.ex `controller`, `view`, and `channel` definitions to use the new `Web` namespace:

    ```diff
    def controller do
    quote do
    ...
    - import Demo.Web.Router.Helpers
    + import Demo.Router.Helpers
    - import Demo.Gettext
    + import Demo.Web.Gettext
    end
    end

    def view do
    quote do
    ...
    - import Demo.Router.Helpers
    + import Demo.Web.Router.Helpers
    - import Demo.ErrorHelpers
    + import Demo.WebErrorHelpers
    - import Demo.Gettext
    + import Demo.Web.Gettext
    end
    end

    def channel do
    quote do
    ...
    - import Demo.Gettext
    + import Demo.Web.Gettext
    end
    end
    ```


    6. Rename all web related modules in `lib/my_app/web/` (gettext.ex, controllers/*, views/*, channels/*, endpoint.ex, router.ex) to include a `Web` namespace, for example:

    * `MyApp.Endpoint` => `MyApp.Web.Endpoint`
    * `MyApp.Router` => `MyApp.Web.Router`
    * `MyApp.PageController` => `MyApp.Web.PageController`
    * `MyApp.PageView` => `MyApp.Web.PageView`
    * `MyApp.UserSocket` => `MyApp.Web.UserSocket`
    * etc

    7. Update all alias in `lib/app_name/web/router.ex` to include new `Web` namespace. Most likely you can accomplish this by adding `.Web` to the second argument of your scope blocks, for example:

    ```diff
    - defmodule MyApp.Router do
    + defmodule MyApp.Web.Router do
    ...
    - scope "/", MyApp do
    + scope "/", MyApp.Web do
    pipe_through :browser

    resources "/users", UserController
    ...
    end
    ```

    8. Update `endpoint.ex` to use new web modules:

    ```diff
    - defmodule MyApp.Endpoint do
    + defmodule MyApp.Web.Endpoint do
    ...
    - socket "/socket", Demo.UserSocket
    + socket "/socket", Demo.Web.UserSocket
    ...
    - plug Demo.Router
    + plug Demo.Web.Router
    ```

    8. in `lib/my_app.ex`, update your children and config_change callback to reference the new endpoint:

    ```diff
    ...
    children = [
    ...
    - supervisor(Demo.Endpoint, []),
    + supervisor(Demo.Web.Endpoint, []),
    ...
    ]

    ...
    def config_change(changed, _new, removed) do
    - Demo.Endpoint.config_change(changed, removed)
    + Demo.Web..Endpoint.config_change(changed, removed)
    :ok
    end

    ```

    8. Update all endpoint aliases in config/*.exs (config.exs, prod.exs, prod.secret.exs dev.exs, test.exs ], etc) aliases to use new `Web` namespace:

    ```diff
    - config :my_app, MyApp.Endpoint,
    + config :my_app, MyApp.Web.Endpoint,
    ...
    - render_errors: [view: MyApp.ErrorView, accepts: ~w(html json)],
    + render_errors: [view: MyApp.Web.ErrorView, accepts: ~w(html json)],
    ...
    ```

    9. Update your live-reload patterns config in `config/dev.exs`:

    ```diff
    - config :demo, MyApp.Endpoint,
    + config :demo, MyApp.Web.Endpoint,
    live_reload: [
    patterns: [
    ~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
    ~r{priv/gettext/.*(po)$},
    - ~r{web/views/.*(ex)$},
    - ~r{web/templates/.*(eex)$}
    + ~r{lib/my_app/web/views/.*(ex)$},
    + ~r{lib/my_app/web/templates/.*(eex)$}
    ]
    ]
    ```

    10. Rename your `test/support/conn_case.ex` and `test/support/channel_case.ex` modules to include `Web` namespace, and update `@endpoint` and router aliases in each:

    ```diff
    -defmodule MyApp.ConnCase do
    +defmodule MyApp.Web.ConnCase do
    using do
    quote do
    ...
    - import MyApp.Router.Helpers
    + import MyApp.Web.Router.Helpers

    # The default endpoint for testing
    - @endpoint MyApp.Endpoint
    + @endpoint MyApp.Web.Endpoint
    end
    end
    ...


    -defmodule MyApp.ChannelCase do
    +defmodule MyApp.Web.ChannelCase do

    using do
    quote do
    ...
    - @endpoint MyApp.Endpoint
    + @endpoint MyApp.Web.Endpoint
    end
    end
    ...
    ```

    11. Update all `test/*/**.exs` references to `use MyApp.ConnCase` or `use MyApp.ChannelCase` to use new `MyApp.Web.ConnCase` and `MyApp.Web.ChannelCase` aliases.

    ### Move static assets inside self-contained assets/ directory

    New projects now include a root-level `assets/` directory, which serves as a self-contained location for your asset builder's config, source files, and packages. This changer keeps things like `node_modules`, `package.json`, and `brunch-config.js` from leaking into the root of your elixir application. Update your app to the new structure by following these steps:

    1) move all `web/static/` sources into `assets/`, followed by `package.json`, `node_modules`, and `brunch-config.js`

    ```console
    $ mv mv lib/my_app/web/static assets/
    $ mv assets/assets assets/static
    $ mv package.json assets/
    $ mv brunch-config.js assets/
    $ rm -rf node_modules
    ```

    2) Update your `asset/package.json` `phoenix` and `phoenix_html` paths:

    ```diff
    "dependencies": {
    - "phoenix": "file:deps/phoenix",
    + "phoenix": "file:../deps/phoenix",
    - "phoenix_html": "file:deps/phoenix_html"
    + "phoenix_html": "file:../deps/phoenix_html"
    },
    ```


    3) Update your `assets/brunch-config.js` to be aware of the new conventions:

    ```diff
    conventions: {
    - // This option sets where we should place non-css and non-js assets in.
    - // By default, we set this to "/web/static/assets". Files in this directory
    - // will be copied to `paths.public`, which is "priv/static" by default.
    - assets: /^(web\/static\/assets)/
    + // This option sets where we should place non-css and non-js assets in.
    + // By default, we set this to "/assets/static". Files in this directory
    + // will be copied to `paths.public`, which is "priv/static" by default.
    + assets: /^(static)/
    },

    paths: {
    // Dependencies and current project directories to watch
    - watched: [
    - "web/static",
    - "test/static"
    - ],
    + watched: ["static", "css", "js", "vendor"],

    // Where to compile files to
    - public: "priv/static"
    + public: "../priv/static"
    },

    plugins: {
    babel: {
    // Do not use ES6 compiler in vendor code
    - ignore: [/web\/static\/vendor/]
    + ignore: [/vendor/]
    }
    },

    modules: {
    autoRequire: {
    - "js/app.js": ["web/static/js/app"]
    + "js/app.js": ["js/app"]
    }
    },
    ```

    4) Update your `config/dev.exs` watcher to run in the new assets directory:

    ```diff
    config :my_app, MyApp.Web.Endpoint,
    ...
    watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin",
    - cd: Path.expand("../", __DIR__)]]
    + cd: Path.expand("../assets", __DIR__)]]


    ```

    5. Install the node deps: `$cd assets && npm install`


    Test it all with `mix phx.server`, and `mix test` and you should see:

    ```
    $ mix phx.server
    [info] Running MyApp.Web.Endpoint with Cowboy using http://0.0.0.0:4000
    01 Mar 15:40:05 - info: compiled 6 files into 2 files, copied 3 in 976ms
    ```