How to upgrade to Phoenix from 0.6.x
to 0.7.0
.
- 0.7.0 depends on Plug HEAD, so you'll need to include plug in your mix deps until the next plug release:
{:plug, github: "elixir-lang/plug", ref: "7040c89cb4cf1f1c6afdee379e5982a07d77a6c3"}
```
1. The `Pheonix.Controller` functions html/2, json/2, text/2, redirect/2 and render/3 no longer halt automatically. *Important*: You must now explicity call `halt/1` yourself if you want to stop invoking further plugs after calling these functions. This is improtant for auth filtering plugs, ie:
```elixir
def authenticate(conn, _) do
if Auth.authenticated?(conn) do
conn
else
conn
|> redirect(to: "/")
|> halt # halt is now required here to stop further plugs
end
end
```
1. Define a Phoenix.Endpoint at `lib/OTP_APP/endpoint.ex`
The [contents for this file can be found here](https://github.com/phoenixframework/phoenix/blob/84f3309668dfec6d5eca587a98c912efb18c7cdc/priv/template/lib/application_name/endpoint.ex) where the values must be replaced by the current values in your config/config.exs file
2. Migrate your config/*.exs files to configure the endpoint in your application instead of the router. In other words, instead of:
config :phoenix, MyApp.Router
You should have:
config :OTP_APP, MyApp.Endpoint
3. Add a `config_change/3` callback to your application. In your `lib/OTP_APP.ex`, simply [add this function](https://github.com/phoenixframework/phoenix/blob/84f3309668dfec6d5eca587a98c912efb18c7cdc/priv/template/lib/application_name.ex#L20-L25).
4. If you are using the `url/1` from `MyApp.Router.Helpers`, it now needs to be accessed from the endpoint, as `MyApp.Endpoint.url/1`. The preferred solution though is to use `MyApp.Router.Helpers.url/2
5. Rename `MyApp.ErrorsView` to `MyApp.ErrorView`.
6. Linguist has been removed as a dependency, and an I18n module is no longer generated in your project. If you are using `MyApp.I18n`, add Linguist to your mix deps, `{:linguist, "~> 0.1.4"}`. If you are not using the `t/3` or `t!/3` I18n functions, you can remove `MyApp.I18n` all together and add it later if needed. Be sure to also remove the `import MyApp.I18n` delclaration from `MyApp.View` if you remove this dep.