ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Auto-registering trait in addon service provider

Open jesseleite opened this issue 7 years ago • 3 comments

It might be cool to include a trait in the addon service provider stub to auto-register fieldtypes/filters/tags/etc. for the user. If the trait is used, the service provider would loop through the appropriate folders, loop over the files, and auto-register everything. If it's too magical for a user, they can remove the use trait statement.

My thought is this... In Laravel, so many times I’ve developed a policy and forgot to register it, only to waste 5 minutes fumbling before realizing. I think I remember a tweet where Taylor said he was working on a convention to auto-register policies with models using a naming convention? That said, there are other things in Laravel that will always require registering, like middleware.

Pros: Make it easier for new users to develop for marketplace. Remove that extra mental step that some people might forget.

Cons: Development time? Any others?

😊

jesseleite avatar Jan 10 '19 15:01 jesseleite

Oh, here's that tweet I mentioned: https://twitter.com/taylorotwell/status/1078494087525908481

jesseleite avatar Jan 10 '19 15:01 jesseleite

Only con I see is development time. We can loop back once were at 3.0 🤘

jasonvarga avatar Jan 10 '19 15:01 jasonvarga

Policies now register themselves in Laravel (see tweet), as long as policies and models are in conventional location.

And if not in conventional location, you can customize how it finds and registers (see tweet)

Maybe we can look into how they do it without adding noticable overhead. Thoughts?

jesseleite avatar Feb 19 '19 04:02 jesseleite