Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Upgrade to Phoenix 4

README - upgrade to phoenix 4.

This conversion was actually done with phoenix master, the week before phoenix 4 released.

Using:

  • Erlang 17.0
  • Elixir 0.15.0
  • Phoenix master, "55577a267a1635af3d19fb5c37381077bd25e484"

Steps:

  1. Create a new Phoenix app.

    Recommend giving it the same name as the target.

    I created a new app: YourApp, while my target app is Thor

  2. Reorganize config dir

    • move config dir to Thor.
    • rename all confix files to extension .exs
    • copy contents of new app config files into target app config files.
    • update values in config files as needed.
    • note the app name is in the config line: config :phoenix, Thor.Router,
    • copy locales from new app to config dir.
  3. Make a web directory under target app. In this example, /thor/web

  4. Copy to web directory

    • directories: controllers, models, queries, templates and views
    • files: router.ex, views.ex
    • copy i18n.ex from new app.
  5. Edit files, rename directories in web directory.

    • controllers: rename files to singular.
    • controllers: module name is PageController
    • templates: rename sub dirs to singular
    • views: rename files to singular in this form: page_view.ex
    • views: module name changes to Thor.PageView
    • router.ex: change controller names as Thor.PageController
    • views.ex: I just copied the contents of the new app views.ex file.
  6. Edit mix.exs:

    Here are some key dependencies.

    • project:

      elixir: "~> 0.15.0",
      elixirc_paths: ["lib", "web"],
      
    • deps:

      {:phoenix, github: "phoenixframework/phoenix"},
      {:cowboy, "~> 1.0.0"},
      {:postgrex, "~> 0.5.4"},
      {:ecto, "~> 0.2.3"},
      
  7. Everything else goes in lib. (probably where it was before)

@Kosmas
Copy link

Kosmas commented Sep 3, 2014

just a quick note that I've upgraded my phoenix application from to 0.4 version from the one before that, and all of the things described above were not necessary.
Only thing that needed to be changed was the elixir version to 1.0.0-rc1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment