Phoenix Application Template customization

The “thing” is a combination of Rails application templates and any generator improvements that go along with being able to do things like make line based changes.

Something like this could be a separate template. One for generating CI files, one for generating Docker related files, etc.

It can follow the same or similar pattern of what Rails Bytes does. You as an end user can pick the things you want to pull into your app.

Railsbytes is a community driven project but it only works because Rails supplies the plumbing for creating the templates and generators.

Do you have a video link of the talk? It’s not listed on the meetup page and the only comment around the video being posted is almost a year old with no updates.

Sorry if I wans’t clear enough - but it still seems “I want a hammer” answer (implementation), not “I need to hang a picture” (problem).

From my experience and observation on package managers and project generator in several languages…

  • Making individual steps independent is theoretically impossible (if it’s possible we will lose our jobs…)
  • Having a few “base templates” and making changes from it is much easier to maintain than having composable steps and using them as needed
  • Language/framework/library conventions and features change a lot, and it is impractical to keep every steps up-to-date to handle them (or let users to update the generator)
  • It’s easier to have extract feature/config into separate component (e.g. rails engine) than making changes in code level
  • Or wrap everything and make like magic if it’s really complicated - create-react-app is an example. This vary a lot by language/framework though

I know there are several useful things (like adding a gem in a group) - but I’m not sure we want to have line based changes tools. It seems like… installing phpbb mod which has “COPY”, “BEFORE ADD”, “AFTER ADD” actions… and leads to "wait I’m using mod X but couldn’t install mod Y due to line conflicts… :wink:

Honestly I (still) believe such tools would add little value than it seems. And probably only way to make the efforts to create such tools worth is… to have language/framework agnostic tool, so that all language/framework can get benefit from it. However, probably that’s too ideal idea (like editorconfig)


I was in that event. Don’t know whether video is available elsewhere :crying_cat_face: @plorry is actually in this forum but not sure he is checking in.


For me, having more consistent, and “better” configuration and documentation is more important in Elixir/Erlang ecosystem than having such tools for now. Examples are:

  • Having types for opts could be useful for docs and (future) type check
  • Separation of responsibility is good… but if there is no good docs then it’s very hard to find out what’s actually supported opts. (e.g. phoenix - plug_cowboy - cowboy, and any libraries using ssl :icon_mad:)

(This can be a separate thread though)

1 Like

Hm… I wanted to have typespec for opts as well but this does not do that.

Probably it won’t be able to do that since the type structure/system is different…

Yeah this is what I did with Rails about 7 years ago with that project I linked before. I had the idea of a ‘base’ project and an ‘auth’ project that builds upon the base.

But that’s unimportant for this discussion IMO.

Right now Rails makes it super easy to make such templates because it includes an entire DSL and framework feature for building these templates. Phoenix does not. That’s why I imagine the OP of this thread started this thread. This feature is immensely popular in other languages and frameworks.

Hi all, we just create the first version for our template, it helps us a lot in creating the new project, If you are interesting, feel free to have a look and give a try on https://github.com/nimblehq/elixir-templates. Feel free to create issues if that doesn’t work with you, any feedback is welcome :heart_eyes:

This is the latest demo from that template, we generate a new project and deploy that to Heroku with Mix Release.

3 Likes

Do you plan to create a solution like Rails where instead of downloading pre-made templates with hard coded solutions and decisions, you have free reign to create your own templates?

Because based on that demo it looks like it basically generates a new Phoenix project with a few more opinions than the default Phoenix generator.

I don’t think we can do that at this time, but base on the current implementation, each team can fork that and custom their own template.

Yeah, that is what we need at the beginning, generate the new project along with some tools, configuration.

In ruby land and a few other languages, I also find it really helpful to have a full project template API with a DSL.

For my use I (and my teams) tend to create a ton of projects/POC etc and have a lot of purely mechanical boilerplate to setup currently in elixir. While the use-case of having the template system “update” an app is not useful for me or my team (I don’t think that tends to work well even for rails), having a system API for building out templates for common app types for a team is huge (it can save hours of boilerplate while also ensuring reproducibility).

An example of what I would use it for:

I want a new Phoenix POC (which may live on past POC)

Use current phenix gen
Add standard libraries and templates etc for auth (including updating config, setting defaults, etc)
pull in standard migrations for user tables
import standard template, setup standard js/css basis
add some standard mix items for CI/DI
setup docker deploy files and scripts

Currently really this can be done ala pheonix-auth-gen mode or a bash script, however it does feel like you are working in the wild (in the case of bash scripting you jump out of the language and phx-auth-gen you get hard locked to maintaining all of the tooling nuts to bolts instead of just the meat of your templates). I totally get the adverse stance against modifying living apps – but the tooling seems pretty lacking for “bootstrapping”. Maybe its just that many folks on the core team don’t bootstrap full POC very often? just my 2c.

We are so excited to announce that our Elixir Template 3.0.0 has been released.

The third major version supports both Phoenix and Non-Phoenix (Mix) projects. That helps you speed up on initializing either a new Mix or Phoenix project. :heart_eyes:

We also renamed the Hex package to nimble_template and made the previous package retired.

Last but not least, we have a better hexdocs documentation for the template. :smile:

Feel free to give it a try and let us know if there is any problem.

Happy coding!

There’s also this for dockerising a phoenix project, this would be a very good base to start from.

1 Like

Hi there, good to know the ex_docker there :slight_smile:

As I have checked, that library hasn’t up to date (last commit since 2018) and it generates 3 files

  • docker-compose.yml
  • Dockerfile
  • Makefile

These files are handled in our template also :smiley:

1 Like