Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-registering trait in addon service provider #88

Closed
jesseleite opened this issue Jan 10, 2019 · 3 comments · Fixed by statamic/cms#9270
Closed

Auto-registering trait in addon service provider #88

jesseleite opened this issue Jan 10, 2019 · 3 comments · Fixed by statamic/cms#9270
Labels
Developer UX feature request New feature or request

Comments

@jesseleite
Copy link
Member

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
Copy link
Member Author

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

@jasonvarga
Copy link
Member

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

@jesseleite
Copy link
Member Author

jesseleite commented Feb 19, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer UX feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants