chrisjowen

chrisjowen

Custom Phoenix/Ecto generators?

Hey All,

Im probably in the minority in that I generally dislike some of the way that the Ecto/Phoenix generators work in and would like to have more control over what they produce. Im not here to argue this, and I havent enough Elixir experience to solidify my arguments againt them.

I usually avoid using them, but for a recent project I tried to get running as quickly as possible and relied on they heavily. I believe that generators are very useful for quick scaffolding and I would use them if they fit my defaults more (which change per project).

With this in mind do we have anything the elixir community that is a generator of generator such as GitHub - foundweekends/giter8: a command line tool to apply templates defined on GitHub · GitHub or https://yeoman.io/?

Note: I’m not looking at these as shining example in their respective ecosystems I have used both and disliked the experience but I have never sat down and thought what good would look like for such a tool I just have a feeling that a flexible easy to use generator would be extreemly useful for me.

Chris

First Post!

adrianrl

adrianrl

Hi,

I’ve used aspnet-codegenerator (extremely opinionated, but flexible) and the generator for Symfony and Laravel, (both are very opinionated, but flexible). I think Phoenix’s generator is poorly opinionated, and flexible enough; it just generates what you need without extra markup. I like being poorly opinionated, the framework shouldn’t make decisions for you, sometimes you don’t want to use Bootstrap as a CSS framework, or jQuery for client-side validation.

However the generator lacks a bit in terms of flexibility, sometimes you don’t want to generate all of the templates or you just want to start from scratch without all of the basic functionality, and for that specific things you may want to build your own generator, it doesn’t have to be perfect, just something that covers your needs.

Most Liked

LostKobrakai

LostKobrakai

You can copy the templates phoenix/priv/templates at main · phoenixframework/phoenix · GitHub into your own priv/templates folder and the mix tasks will use those. You’re free to edit them there.

27
Post #3
type1fool

type1fool

Thank you for the link. This should be documented.

jg-made

jg-made

Has anyone out there made any LiveView generators? If so, would you please share? :slight_smile:

Last Post!

OndrejValenta

OndrejValenta

I’m planning to use for our projects LLBLGen, which was originally intended for .NET projects but their generators are quite universal and they are developing their tools for at least 15 years what I can remember.

We are now investigating how ecto files actually look like for real aplications and then we’ll look into the templates.

It’s not free but it has quite powerful UI and you can pretty well set up how you want to generate your models. It can even create typed views for database views or stored procedures.

It deals only with RDBMS though and it also has some issues with postrgres custom types and enums.

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New