{"__v":0,"_id":"54fd05a8929ca119008ae8f1","initVersion":{"_id":"54e51b71d71c112d0054410f","version":"0.9.0"},"project":"54348ec95b10711400c6c445","tags":[],"user":{"_id":"54348e770ef9c008001651d4","username":"","name":"Chris McCord"},"createdAt":"2015-03-09T02:30:00.990Z","changelog":[],"body":"We released Phoenix 0.10.0 this weekend and we're really excited to\nshare the new features we've been working on. This release brings an\nasset build system powered by [brunch](http://brunch.io), live-reloading of\ncss/js/eex templates, form builders, and new [Ecto](https://github.com/elixir-lang/ecto) integration with generators\nthat lets you get up and running quickly.\n\nThere's so much good stuff packed into this release, that it deserved\na screencast so you can see it in action:\n[block:embed]\n{\n  \"html\": \"<iframe class=\\\"embedly-embed\\\" src=\\\"//cdn.embedly.com/widgets/media.html?src=http%3A%2F%2Fwww.youtube.com%2Fembed%2FNh5OQjb8G9E%3Ffeature%3Doembed&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNh5OQjb8G9E&image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FNh5OQjb8G9E%2Fhqdefault.jpg&key=02466f963b9b4bb8845a05b53d3235d7&type=text%2Fhtml&schema=youtube\\\" width=\\\"640\\\" height=\\\"480\\\" scrolling=\\\"no\\\" frameborder=\\\"0\\\" allowfullscreen></iframe>\",\n  \"url\": \"https://www.youtube.com/watch?v=Nh5OQjb8G9E\",\n  \"title\": \"Phoenix 0.10.0 Overview\",\n  \"favicon\": \"https://s.ytimg.com/yts/img/favicon-vfldLzJxy.ico\",\n  \"image\": \"http://i.ytimg.com/vi/Nh5OQjb8G9E/hqdefault.jpg\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Live-Reload\"\n}\n[/block]\nChange any css, js, or EEx template, and watch the browser instantly\nreload with your changes. The best part is that we don't need any browser plugin. Everything is powered by Phoenix channels and works regardless of your javascript tooling of choice. Try it out–you'll love it.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Static Asset Handling\"\n}\n[/block]\nWe've integrated Brunch for fast and simple asset\ncompilation that Just Works. When you start your `mix phoenix.server`\nin development, a brunch process is run automatically alongside your\nendpoint and your assets in `web/static/js` and `web/static/css` will\nbe compiled as the files change. Even better, with our new live-reload\nfeature, those recompiles get reloaded in the browser for a\nstreamlined development experience. We've also built Brunch\nintegration in a way that will let you wire up your own asset system,\nsuch as Gulp, Grunt, Webpack, etc.\n\nOut of the box, we support Sass and ES6 javascript compilation, but\nit's very easy to extend your `brunch-config.js` with additional tools\nto support your asset workflow.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Ecto Integration, New Protocols, Form & Link Builders\"\n}\n[/block]\nThis release brings two new protocols, `Phoenix.HTML.FormData` and\n`Phoenix.Param` that makes it simple to integrate your model layer\nwith Phoenix's new form and link builders. As a default, but optional\ndep, we now include Ecto integration through the\n[phoenix_ecto](https://github.com/phoenixframework/phoenix_ecto)\nproject where you can see these two new protocols in action. Let's check it out:\n\n```erb\n<%= form_for @changeset, @action, fn f -> %>\n  <%= if @changeset.errors != [] do %>\n    <p style=\"color: red\">Oops, something went wrong!</p>\n  <% end %>\n\n  <p>\n    <label>\n      <span>Title:</span>\n      <%= text_input f, :title %>\n    </label>\n  </p>\n\n  <p>\n    <label>\n      <span>Rank:</span>\n      <%= number_input f, :rank %>\n    </label>\n  </p>\n\n  <p>\n    <%= submit \"Submit\" %>\n  </p>\n<% end %>\n```\n\n`form_for` accepts an Ecto changeset here, but will support any data\nstructure that implements the `FormData` protocol. With form builders,\nwe inject the CSRF token for you automatically to verify requests and\nyou can enjoy the new form input helpers, ie `text_input`,\n`number_input`.\n\nIn addition to forms, we now include a `link` function for building\nanchors in your templates:\n\n```erb\n<%= for post <- @posts do %>\n  <tr>\n    <td><%= post.title %></td>\n    <td><%= post.rank %></td>\n\n    <td><%= link \"Show\", to: post_path(@conn, :show, post) %></td>\n    <td><%= link \"Edit\", to: post_path(@conn, :edit, post) %></td>\n    <td><%= link \"Delete\", to: post_path(@conn, :delete, post), method: :delete %></td>\n  </tr>\n<% end %>\n```\n\nNotice how we able to write `post_path(@conn, :show, post)` instead of\n`post_path(@conn, :show, post.id)`? This is thanks to the new\n`Phoenix.Param` protocol that lets you define how resources should be\nconverted to paths and URLs. You may have also noticed the `method:\n:delete` option. This will convert the link tag into a form submission,\nas a DELETE request, and will inject the CSRF token for you. It's\nhandy for quick links to delete or update a resource without having to\nbuild a form yourself.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Resource Generator\"\n}\n[/block]\nThe Ecto integration includes a new `mix phoenix.gen.resource` task\nthat bootstraps a model with boilerplate code generation that lets you\nget up to speed quickly with Phoenix and Ecto and start building\napplications right away. From a single command like:\n\n```console\nmix phoenix.gen.resource Post posts title:string rank:integer\n```\n\nA migration file is created with the provided schema and the model,\nview, template, and controller files are generated for CRUD actions.\nIt's a great way to learn the basics of Phoenix and experience the\nlatest and greatest Ecto features.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Upgrading from 0.9.x\"\n}\n[/block]\nSee these [0.9.x to 0.10.0 upgrade instructions](https://gist.github.com/chrismccord/cf51346c6636b5052885) to bring your existing apps up to speed.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Get Involved\"\n}\n[/block]\n\nThat's Phoenix 0.10.0. In case you missed it in the previous release, we have done many improvements to our channel system, including support for 3rd party backends, starting with Redis. Now we have streamlined the development experience. We have some big announcements coming soon as\nwe head towards 1.0, so keep up to date by subscribing to the\n[phoenix-core](https://groups.google.com/forum/#!forum/phoenix-core) and [phoenix-talk](https://groups.google.com/forum/#!forum/phoenix-talk) mailing lists, and get involved on\n[#elixir-lang IRC](irc://irc.freenode.net/elixir-lang). Feel free to join in and ask questions, and provide\nhelp to others.\n\nHappy coding!","slug":"phoenix-0100-released-with-assets-handling-generat","title":"Phoenix 0.10.0 released with assets handling, generators, & more"}

Phoenix 0.10.0 released with assets handling, generators, & more


We released Phoenix 0.10.0 this weekend and we're really excited to share the new features we've been working on. This release brings an asset build system powered by [brunch](http://brunch.io), live-reloading of css/js/eex templates, form builders, and new [Ecto](https://github.com/elixir-lang/ecto) integration with generators that lets you get up and running quickly. There's so much good stuff packed into this release, that it deserved a screencast so you can see it in action: [block:embed] { "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=http%3A%2F%2Fwww.youtube.com%2Fembed%2FNh5OQjb8G9E%3Ffeature%3Doembed&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNh5OQjb8G9E&image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FNh5OQjb8G9E%2Fhqdefault.jpg&key=02466f963b9b4bb8845a05b53d3235d7&type=text%2Fhtml&schema=youtube\" width=\"640\" height=\"480\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "url": "https://www.youtube.com/watch?v=Nh5OQjb8G9E", "title": "Phoenix 0.10.0 Overview", "favicon": "https://s.ytimg.com/yts/img/favicon-vfldLzJxy.ico", "image": "http://i.ytimg.com/vi/Nh5OQjb8G9E/hqdefault.jpg" } [/block] [block:api-header] { "type": "basic", "title": "Live-Reload" } [/block] Change any css, js, or EEx template, and watch the browser instantly reload with your changes. The best part is that we don't need any browser plugin. Everything is powered by Phoenix channels and works regardless of your javascript tooling of choice. Try it out–you'll love it. [block:api-header] { "type": "basic", "title": "Static Asset Handling" } [/block] We've integrated Brunch for fast and simple asset compilation that Just Works. When you start your `mix phoenix.server` in development, a brunch process is run automatically alongside your endpoint and your assets in `web/static/js` and `web/static/css` will be compiled as the files change. Even better, with our new live-reload feature, those recompiles get reloaded in the browser for a streamlined development experience. We've also built Brunch integration in a way that will let you wire up your own asset system, such as Gulp, Grunt, Webpack, etc. Out of the box, we support Sass and ES6 javascript compilation, but it's very easy to extend your `brunch-config.js` with additional tools to support your asset workflow. [block:api-header] { "type": "basic", "title": "Ecto Integration, New Protocols, Form & Link Builders" } [/block] This release brings two new protocols, `Phoenix.HTML.FormData` and `Phoenix.Param` that makes it simple to integrate your model layer with Phoenix's new form and link builders. As a default, but optional dep, we now include Ecto integration through the [phoenix_ecto](https://github.com/phoenixframework/phoenix_ecto) project where you can see these two new protocols in action. Let's check it out: ```erb <%= form_for @changeset, @action, fn f -> %> <%= if @changeset.errors != [] do %> <p style="color: red">Oops, something went wrong!</p> <% end %> <p> <label> <span>Title:</span> <%= text_input f, :title %> </label> </p> <p> <label> <span>Rank:</span> <%= number_input f, :rank %> </label> </p> <p> <%= submit "Submit" %> </p> <% end %> ``` `form_for` accepts an Ecto changeset here, but will support any data structure that implements the `FormData` protocol. With form builders, we inject the CSRF token for you automatically to verify requests and you can enjoy the new form input helpers, ie `text_input`, `number_input`. In addition to forms, we now include a `link` function for building anchors in your templates: ```erb <%= for post <- @posts do %> <tr> <td><%= post.title %></td> <td><%= post.rank %></td> <td><%= link "Show", to: post_path(@conn, :show, post) %></td> <td><%= link "Edit", to: post_path(@conn, :edit, post) %></td> <td><%= link "Delete", to: post_path(@conn, :delete, post), method: :delete %></td> </tr> <% end %> ``` Notice how we able to write `post_path(@conn, :show, post)` instead of `post_path(@conn, :show, post.id)`? This is thanks to the new `Phoenix.Param` protocol that lets you define how resources should be converted to paths and URLs. You may have also noticed the `method: :delete` option. This will convert the link tag into a form submission, as a DELETE request, and will inject the CSRF token for you. It's handy for quick links to delete or update a resource without having to build a form yourself. [block:api-header] { "type": "basic", "title": "Resource Generator" } [/block] The Ecto integration includes a new `mix phoenix.gen.resource` task that bootstraps a model with boilerplate code generation that lets you get up to speed quickly with Phoenix and Ecto and start building applications right away. From a single command like: ```console mix phoenix.gen.resource Post posts title:string rank:integer ``` A migration file is created with the provided schema and the model, view, template, and controller files are generated for CRUD actions. It's a great way to learn the basics of Phoenix and experience the latest and greatest Ecto features. [block:api-header] { "type": "basic", "title": "Upgrading from 0.9.x" } [/block] See these [0.9.x to 0.10.0 upgrade instructions](https://gist.github.com/chrismccord/cf51346c6636b5052885) to bring your existing apps up to speed. [block:api-header] { "type": "basic", "title": "Get Involved" } [/block] That's Phoenix 0.10.0. In case you missed it in the previous release, we have done many improvements to our channel system, including support for 3rd party backends, starting with Redis. Now we have streamlined the development experience. We have some big announcements coming soon as we head towards 1.0, so keep up to date by subscribing to the [phoenix-core](https://groups.google.com/forum/#!forum/phoenix-core) and [phoenix-talk](https://groups.google.com/forum/#!forum/phoenix-talk) mailing lists, and get involved on [#elixir-lang IRC](irc://irc.freenode.net/elixir-lang). Feel free to join in and ask questions, and provide help to others. Happy coding!