A Laravel Repository generator with the best practice and tools already set and ready to be used.
- Commands to generate files, including repository files and others.
- Enforcing single responsibility principle
- Automatic CRUD out-of-the-box, whenever you generate a repository it will be CRUD-ready.
- Automatic query searching - (when the frontend send search GET param)
- Automatic query sorting - (when the frontend send order GET param)
- Automatic query filtration
This package aim to provide auto file generation and base classes for the repository design pattern on Laravel.
Repository pattern forces you to have repository files in mediate between controllers and models, acting like a container where data access logic and business logic are stored.
MVC Violate the single responsibility principle in SOLID principles, where controller methods are responsible for the business logic and returning responses to the front-end users in the same time, making it impossible to re-use these methods or to independently testing the business logic in them.
After a request is being sent to the Laravel application, it follows these steps:
- The route catch the request and redirect it to its method in the controller
- The controller then validate the request with the correct request file.
- If the validations passed, the controller then check the policy authorization if available.
- If it passed the controller then call the repository to retrieve the required data.
- The repository implement the business logic and call the model to retrieve the required data from the database accordingly.
- The repository process that data (if needed) and return the final result to the controller
- The controller passes that data to the resource file to format the data as needed.
- The controller finally return the response back to the user.
Run:
php artisan generate:repository Test
This will generate the following files:
- Test - (the Model file)
- TestController
- TestRepository
- TestRequest
- TestResource
- TestPolicy
- TestTest
Read the full document on ReadTheDoc.
MIT License
We follow Semantic Versioning
- add the ability to disable caching from the config.