Exciting things cooking up for Phoenix 1.7

Anyone else excited for the upcoming changes in Phoenix 1.7? :fire:

Looks like phoenix_view is getting deprecated in favour of phoenix_template:

With Phoenix.LiveView, Phoenix.View has been replaced by Phoenix.Component. Phoenix.Component is capable of embedding templates on disk as functions components, using the embed_templates function. For example, in Phoenix v1.7+, the YourAppWeb.UserView above would be written as:

defmodule YourAppWeb.UserHTML do
  use YourAppWeb, :html

  embed_templates "users"
end

The benefit of Phoenix.Component is that it unifies the rendering of traditional request/response life cycles with the composable component model provided by LiveView.

Replace use MyApp, :view by use MyApp, :html and invoke embed_template “…/templates/my”. Alternatively, you can move both the HTML file and its templates to the controllers directory, to align with Phoenix v1.7 conventions.

More details here.

Not sure what exactly are the 1.7 conventions, but I’m guessing this is the recurring idea of colocating controller, view and templates.

I have a non-trivial app that uses Phoenix views (“dead views”; non-live views). I’ve adopted the colocating approach and recently did full migration to Phoenix.Component-based views. My view macro is basically this:

  def view do
    quote do
      use Phoenix.View,
        root: "lib/myapp_web",
        namespace: MyAppWeb

      # x- prefix for Alpine.js
      use Phoenix.Component, global_prefixes: ["x-"]

      import MyAppWeb.Components
      import Heroicons.LiveView

      # ...
    end
  end

I believe that Phoenix is really pushing the boundaries of modern web apps, including traditional request-response ones. Amazing stuff :clap:

24 Likes

I’m just excited for 1.7 - hope it drops soon! :slight_smile:

4 Likes

Me three! Maybe we should place our guesses on when we might see it? :lol:

5 Likes

Verified routes!

6 Likes

I have been eyeing Milestone, for Phoenix Framework, every day:

It’s currently at 79%!!


  • I am excited about StoryBook.
  • The new redesigned Tailwind CSS templates, that will get generated.
  • The live auth flow, that will come by default.
  • The new flash slot approach, for modern toast message.
  • Verified Routes.

I might end up listing every feature. :sweat_smile:

16 Likes

Phoenix 1.7 and LiveView 0.18 ETA? - #6 by cvkmohan here I have predicted 2 weeks for both LiveView 0.18 and Phoenix 1.7. LiveView became a reality in two weeks - however, I got the date for Phoenix completely wrong.
Though we may never know the internal planned date by @chrismccord and @josevalim - my suspicion is they added more features to Phoenix as an afterthought into the current version - hence the delay.
In @chrismccord talk at elixir conf - he said merging/removing layouts as a roadmap item - but - it is getting delivered in this release.
Anyway, all excited to receive the new release.

PS: I initially wrote Phoenix is delayed - on re-reading I realized it is offensive. The problem is with my anticipation - not with the release date - because there was no commitment on any date.

4 Likes

its 100% now!

11 Likes

On top of everything else, I’m really looking forward to phx_gen_auth generating live views. I’m prototyping a new project and was not looking forward to doing the conversion myself yet again. Many thanks and much appreciation to @bemesa21 for doing all that work.

7 Likes

I’m still not sure why the devs went with a sigil instead of a function/macro.
Something like r("some_route/:id", %{id: id}) to avoid manual string concatenations with the plus side of making it really easy to grep/search and replace.

In the end I cant say I will miss the router helpers as they are today :slight_smile:

With having the parameters separate you either can’t put in a map like this r("some_route/:id", map) or you won’t have compile time error messages around missed keys.

3 Likes

Changelog for Phoenix got updated a bit:

Woah are we really that close to seeing it?!

Just noticed this blog post by Chris - haven’t read it yet but it mentions 1.7…

12 Likes

I have been away from Phoenix for longer than I should have, this HTML aware component is new to me. Will look into this. Phoenix 1.7 looks so good. Thanks for giving me the nudge to get back!

2 Likes

The p macro could disallow anything that wasn’t a map with constant keys in that case. Personally I rather like the p macro.

That’ll be confusing at best for beginners, as a map can only be confirmed constant by a macro if it’s provided inline. You cannot do those checks if the map is passed assigned to a variable. This severly limits the usefulness of having a map in the first place (no composition or dynamic aggregation).

You could do the following, but at that point it’s not far from the string interpolation, though a lot more verbose.

map = %{…}
p("/some/:id/path/:another_id", %{id: map.id, another_id: map.another_id})

While I do agree that the path part here is a lot simpler to search/replace, I doubt the same is the case once the dynamic parts of the path change as well.

That was a really nice blog post! If you haven’t read it is well worth a read :023:

From the blog:

In general, the tightly coupled parts of your application should be as close as practically possible. If not the same file, then the same directory, and so on.

I completely agree with that! :sunglasses:


Btw if anyone’s interested here’s another good blog post about 1.7:


Welcome back Mafinar! Programming LiveView book club soon? :003:
(If anyone else is interested in joining please PM me, I should be able to get you a copy :D)

5 Likes

Hey @cvkmohan, sorry for asking you that again! :smiling_imp:
If you had to repeat this exercise, what new delay would you bet on for the announcement of Phoenix 1.7? Two weeks, one month? All these new things are really exciting for sure! ^^

3 Likes

Hey @Kurisu, Thanks for asking. Yes, I would like to guess again. I do believe we are <2 Weeks into the release of Phoenix 1.7.
Firstly, v1.7 Milestone (github.com) - where all the issues in the milestone are resolved.
Secondly, all the moving parts in the new release mix.exs - live dashboard, liveview and others are moved to semvers rather than pointing to github.
Finally, the commit history is showing mainly typos and trivial documentation changes for the last few days. It means - no major issues pending.
So, my estimate is again 2 weeks. Even a broken clock will be right two times a day - so why not attempt guessing again?

BTW, I am creating new applications using master branch - and - it is working flawlessly so far.

9 Likes

Great! I started working on a new LiveView based project for a client a while back, and the project actually had to be postponed for a while. We’re starting again pretty soon so it looks like I’ll be able to use some of these new goodies. LiveView auth is definitely one!

It’s been a while since I watched the keynote that announced a bunch of these features but if I recall correctly Chris McCord hinted a bunch of stuff that would be coming in future releases and I am looking forward to seeing what these will look like in time.

One that I think will be particularly interesting is the proposed fresh look at validating forms — a really easy to use and powerful forms API could be huge.

Anyway, thanks to all the contributors for the upcoming release! Lots of happy devs in this thread :slight_smile:

4 Likes