I want to start my Phoenix Elixir FolkBot project and want to see if I can implement some of the new features today.
I should be simply using the latest release and upgrading them, and I might revert, but lets see what we can learn now.
Fork the Phoenix Framework repo
I had the honor of being the 1000th fork of the Phoenix Framework, Phoenix project and I will use Gitkraken to review the changes and JetBrains IDEA to review the code in some detail.
Based on the Electron IDE, which is also the basis of the Atom IDE, Gitkraken is a cross-platform GIT code review tool.
Gitkraken is perfect for moments like this where there are a few branches and and I want to understand the significant commits.
we can select a branch and see on the right side what changes where made to what files
We can see in this commit abc685656ab37f4a9ec8502f91ab406f422cbce7 that a bunch of big changes occurred “Add phx.gen.html and phx.gen.schema”.
Now we have a sense of what files we want to review, lets install JetBrains IDEA.
We install the JetBrains Toolbox app to allow us to install and update applications.
Once Jetbrains IDEA is installed we open the Phoenix GIT repo which is checked out to the “cm-phx-gen-next” branch.
We install the Elixir Plugins, restart and now we can view some of the files and changes.
Some New Files
The new files we are interested in are
one of the key changes is the Schema and Context which is explained in the docs, the generators are chained and the generator with the largest scope is
Generates controller, views, and bounded context for an HTML resource.
mix phx.gen.html Accounts User users name:string age:integer
The first argument is the context name followed by
the schema module and its plural name (used for resources and schema).
The above generated resource will contain:
* a context module in lib/accounts.ex, serving as the API boundary to the resource * a schema in lib/accounts/user.ex, with an `accounts_users` table * a view in lib/web/views/user_view.ex * a controller in lib/web/controllers/user_controller.ex * a migration file for the repository * default CRUD templates in lib/web/templates/user * test files for generated context and controller features
another big, significant commit is fb5c340e351715ecd324d3d8ceb18b4f0c779d5a
anyways, lots to explore