"Programming Phoenix" book: Which version of Ph. Framework to install?

I’m about to tackle Phoenix with the book “Programming Phoenix”.

The book instructs to install Phoenix from https://github.com/phoenixframework/archives/raw/
/master/phoenix_new.ez

As far as I can tell this version of Phoenix comes with Ecto 2.0 which breaks a number of examples from the book.

Which is the last 1.1.x version of the Phoenix framework that will work with the book - would that be “phoenix_new-1.1.6.ez”?
(Currently installed versions of Erlang and Elixir are: 19.0.2 / 1.3.2.)

One additional question: How do I get rid of the installed Phoenix 1.2.0? Just delete the directory from the .mix/archives/ or does it have to be removed via mix. If so, how?

Thanks in advance!

6 Likes

Stick with phoenix_new 1.1.6 for the book. The changes are few but it will help avoid confusion in case you get stuck somewhere. Migrating to 1.2.0 should be straight-forward later on.

About the archives, you can either use mix archive.uninstall or just remove the directory manually. Both are fine.

Have fun!

5 Likes

That was my thinking. Problems will most inevitably come. :wink:

Thanks!

1 Like

I’ve done this, versions I’m running:
Erlang/OTP 19
Elixir 1.3.4
phoenix_new-1.1.6

…but have problems with ecto when compiling the throwaway project:

== Compilation error on file lib/phoenix_ecto/html.ex ==
** (KeyError) key :model not found in: %Phoenix.HTML.Form{data: nil, errors: {{:., [line: 12], [{:changeset, [line: 12], nil}, :errors]}, [line: 12], []}, hidden: [], id: {:name, [line: 10], nil}, impl: Phoenix.HTML.FormData.Ecto.Changeset, index: nil, name: {:name, [line: 11], nil}, options: [], params: %{}, source: {:changeset, [line: 8], nil}}
(stdlib) :maps.update(:model, {:model, [line: 13], nil}, %Phoenix.HTML.Form{data: nil, errors: {{:., [line: 12], [{:changeset, [line: 12], nil}, :errors]}, [line: 12], []}, hidden: [], id: {:name, [line: 10], nil}, impl: Phoenix.HTML.FormData.Ecto.Changeset, index: nil, name: {:name, [line: 11], nil}, options: [], params: %{}, source: {:changeset, [line: 8], nil}})
lib/phoenix_html/form.ex:170: anonymous fn/2 in Phoenix.HTML.Form.struct/1

I found this related issue on github:

The proposed solution is to upgrade to Phoenix 1.2, which seems to defeat the issue of working with 1.16 in order to be compatible with the book. It is also suggested that the issues has been fixed with 1.16, but, alas, I’m seeing the problem still.

Any suggestions?

Can you please check if adding {:phoenix_ecto, "~> 2.6.0"} to your mix.exs under the deps section fixes the issue?

Sorry, the instruction above is wrong. You should fix both of those dependencies in your mix.exs:

{:phoenix_ecto, "~> 2.0.1"},
{:phoenix_html, "~> 2.6.0"},
1 Like

Thanks! Sorry, my bad.

I had actually tried that before, but apparently forgot to rerun ‘mix deps.get’ after updating the mix.exs