Download the PHP package aboaisheh/laravel-repository without Composer
On this page you can find all versions of the php package aboaisheh/laravel-repository. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aboaisheh/laravel-repository
More information about aboaisheh/laravel-repository
Files in aboaisheh/laravel-repository
Package laravel-repository
Short Description A Laravel package for generating repositories and services
License MIT
Informations about the package laravel-repository
Laravel Repository Package
A powerful package for generating repositories and services in Laravel applications. It simplifies the implementation of the repository pattern, promoting clean architecture and separation of concerns.
Features
- Create repositories that adhere to a common contract.
- Automatically inject models into repositories.
- Optionally generate corresponding services for repositories.
- Compatible with all Laravel versions from 5.x to 10.x and beyond.
Installation
1. Require the Package
Install the package using Composer:
Usage
1. Generate a Repository
To generate a new repository, use the Artisan command:
For example:
This command creates:
- Repository:
app/Repositories/UserRepository.php
To also generate a service along with the repository, use the --service flag:
This will create:
- Repository:
app/Repositories/UserRepository.php - Service:
app/Services/UserService.php
2. Repository Example
Generated Repository (UserRepository.php):
3. Using Repositories in Controllers
Inject the repository or service into your controllers:
Example Controller:
Customization
You can now generate only the repository or both the repository and service, depending on your requirements.
Generate Repository Only
Generate Repository with Service
This flexibility allows you to use only what you need, keeping your project clean and efficient.
License
This package is open-sourced software licensed under the MIT License.