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

Interface best practice #135

Open
jocelinkisenga opened this issue May 6, 2022 · 5 comments
Open

Interface best practice #135

jocelinkisenga opened this issue May 6, 2022 · 5 comments

Comments

@jocelinkisenga
Copy link

What about using interface with repository classes?

@JohnnyWalkerDigital
Copy link
Contributor

JohnnyWalkerDigital commented Aug 4, 2022

My opinion: The repository pattern is the devil and should be avoided. It's taking SOLID to unnecessary levels with an ORM framework. Otherwise just store interfaces in Contracts/

@jocelinkisenga
Copy link
Author

but for me, i like using repo than interfaces

@carlos-mora
Copy link

We need more than "I like it". In general there is a significant positioning against repositories in Laravel, mainly because it relies in an Active record pattern, and its advantages are lost when Models are isolated in Repos.
In terms of Models, Laravel's style mean the use of Concerns to compose behavoir. That means that every functionality should also be exposed explicitly in Repos, what makes things complex.

@jocelinkisenga
Copy link
Author

how that things can get complex? give your real example of using repo pattern

@spekulatius
Copy link
Contributor

Hello everyone,

adding my 2-cent to the discussion about repo patterns:

From working on a larger, aged applications with repos, the repos didn't add much benefit IMHO. The repo pattern seems to work better for frameworks without strong ORM or even completely without any ORM. With Laravel most of the value from repos comes from abstracting a few setters/getters away and being more DRY. The setters and getters are covered with Eloquent pretty good already I think. The DRY part can easily achieved with an actions nicely I would argue. Can you share where you see the advantages @jocelinkisenga?

Cheers,
Peter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants