Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
I have implemented dependency injection for repositories in a Laravel project. The repository inherits a certain interface, and by the name of this interface, classes receive data from the repository. During the development process, instead of the repositories themselves, I introduce an intermediate caching layer that implements the same interface, but gives the cache instead of accessing the database (I won’t give the code, the project is under NDA).
Another example is mock objects when testing. You can also look at frameworks, polymorphism is actively used there, for example, so that you can use different database engines, save files to a remote server via FTP, and not to your own, by changing only one word in the config and without changing the code in your classes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question