Looking to hire Laravel developers? Try LaraJobs

laravel-repository-pattern maintained by dev-danno

Description
Repository pattern implementation with simple commands in your Laravel application.
Author
jcb
Last update
2025/04/26 00:27 (dev-main)
License
Links
Downloads
12

Comments
comments powered by Disqus

Laravel Repository Pattern Package

Packagist License

This package is to implement the Repository Pattern with Laravel. It includes the creation and register of a custom ServiceProvider. It includes the binding in the ServiceProvider. It includes the creation of Model, Interface & implementation, Service class and Controller. Optional, includes creation and implementation of an Api Response Class.

[!NOTE] This package is compatible with Laravel >= 9

[!CAUTION] Use this package only if you required and plan to use a Repository Pattern based on Interface & Repository Class and dependency injection.

Installation 📌

  • Require the package using composer.
composer require dev-danno/laravel-repository-pattern --dev
  • Laravel uses Auto-Discovery, so it doesn't require to manually add the ServiceProvider.

  • Publish the config file

php artisan vendor:publish --tag=repository-pattern-config

Usage 🧰

[!NOTE] When using interface --repository or model --csir commands, it will automatically create the custom ServiceProvider & register it.

  • Api Response Class
php artisan make:response
  • Interface with resources
php artisan make:interface
  • Interface with resources, Repository class with resources and the corresponding binding.
php artisan make:interface --repository
  • Model with base structure
php artisan make:model
  • Model, Interface & Repository with resources, Service & Controller class with resources and Dependency Injection.

[!NOTE] If ApiResponseHelper class exists, the controllers will include it in the responses.

php artisan make:model --csir