khaledweka / repository-generator
A Laravel package to generate repository pattern files based on models
v1.2
2025-04-28 18:26 UTC
Requires
- php: ^8.0
- laravel/framework: ^9.0|^10.0|^11.0|^12.0
This package is auto-updated.
Last update: 2025-08-28 19:15:28 UTC
README
A Laravel package to generate repository pattern files based on your models.
Installation
- Install the package via composer:
composer require khaledweka/repository-generator
Publish the configuration file (optional):
php artisan vendor:publish --provider="khaledweka\RepositoryGenerator\RepositoryGeneratorServiceProvider"
Usage Generate repository files for a specific model:
php artisan make:repository User
Generate repository files for all models:
php artisan make:repository --all
Features Generates contract interfaces for repositories
Generates repository classes that extend BaseRepository
Automatically updates the RepositoryServiceProvider
Follows your existing repository pattern implementation
How to Use
- Install the package in your Laravel project
- Run the command to generate repositories:
- For a specific model:
php artisan make:repository User
- For all models:
php artisan make:repository --all
- For a specific model:
- The package will generate:
- Contract interface in
app/Repositories/Contracts/
- Repository class in
app/Repositories/SQL/
- Update the
RepositoryServiceProvider
- Contract interface in
Key Features
- Follows your existing repository pattern implementation
- Generates proper type hints and method signatures
- Automatically binds contracts to implementations in the service provider
- Supports generating repositories for all models at once
- Maintains your existing base repository structure
The package will save you significant time when implementing the repository pattern in your Laravel applications by automating the boilerplate code generation.