Phoenix 1.5 requires Elixir >= 1.7. Be sure your existing version is up to date by running elixir -v
on the command line.
$ mix archive.uninstall phx_new
$ mix archive.install hex phx_new 1.5.0
Update your Phoenix and Phoenix PubSub deps to their latest versions.
Note: The outdated Phoenix.Endpoint.CowboyAdapter for Cowboy 1 is deprecated. Please make sure {:plug_cowboy, "~> 2.1"}
is specified in your deps.
defp deps do
[
{:phoenix, "~> 1.5.0"},
{:phoenix_pubsub, "~> 2.0"},
{:plug_cowboy, "~> 2.1"},
...
]
end
Phoenix.PubSub 2.0 provides a simpler, more extensible, and more performant Phoenix.PubSub API. For users of Phoenix.PubSub, the API is the same, but the pubsub server being started by the endpoint has been deprecated in favor of starting the PubSub server yourself. This prevents race conditions on startup and decouples the PubSub system from the endpoint.
First, replace your endpoint's :pubsub
config with a new :pubsub_server
key in config/config.exs
:
config :my_app, MyApp.Endpoint,
url: [host: "localhost"],
...,
- pubsub: [name: MyApp.PubSub, adapter: Phoenix.PubSub.PG2],
+ pubsub_server: MyApp.PubSub,
Next, update your lib/my_app/application.ex
supervision tree to start its own PubSub:
children = [
+ # Start the PubSub system
+ {Phoenix.PubSub, name: MyApp.PubSub},
# Start the Endpoint (http/https)
MyApp.Endpoint,
]
Rendering the child template from layouts is deprecated. Replace:
<%= render(@view_module, @view_template, assigns) %>
With the new @inner_content
assign:
<%= @inner_content %>
Using Phoenix.ConnTest
is deprecated, replace usage:
use Phoenix.ConnTest
with:
import Plug.Conn
import Phoenix.ConnTest
Note: for most applications, this will be located in a single place in test/support/conn_case.ex
The new LiveDashboard project provides real-time performance monitoring and debugging tools for Phoenix developers. Follow the steps in the project readme to include it in your existing applications https://github.com/phoenixframework/phoenix_live_dashboard
There is a difference in how
render/3
handles assigns which you should be aware of when migrating.On Phoenix v1.4
render/3
was only checking if assigns is a map with theis_map/1
guard. This is also true for structs.https://github.com/phoenixframework/phoenix/blob/v1.4.0/lib/phoenix/view.ex#L387
On Phoenix v1.5
render/3
is piping assigns intoMap.new/1
which only works for enumerables, which by default is not implemented for structs. Structs have to specifically implement enumerable protocol.https://github.com/phoenixframework/phoenix/blob/v1.5.7/lib/phoenix/view.ex#L298
@epinault, features being added would be upgrading, which is not required when migrating. Though I agree it is helpful to mention here.