PHPackages                             aboaisheh/laravel-repository - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. aboaisheh/laravel-repository

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

aboaisheh/laravel-repository
============================

A Laravel package for generating repositories and services

v1.0.1(1y ago)25MITPHPPHP &gt;=7.2

Since Nov 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/aboaishehmohammed/laravel-repository)[ Packagist](https://packagist.org/packages/aboaisheh/laravel-repository)[ RSS](/packages/aboaisheh-laravel-repository/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (3)Used By (0)

Laravel Repository Package
==========================

[](#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**
------------

[](#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**
----------------

[](#installation)

### **1. Require the Package**

[](#1-require-the-package)

Install the package using Composer:

```
composer require aboaisheh/laravel-repository
```

---

**Usage**
---------

[](#usage)

### **1. Generate a Repository**

[](#1-generate-a-repository)

To generate a new repository, use the Artisan command:

```
php artisan make:repository ModelName
```

For example:

```
php artisan make:repository User
```

This command creates:

- **Repository**: `app/Repositories/UserRepository.php`

To also generate a service along with the repository, use the `--service` flag:

```
php artisan make:repository User --service
```

This will create:

- **Repository**: `app/Repositories/UserRepository.php`
- **Service**: `app/Services/UserService.php`

---

### **2. Repository Example**

[](#2-repository-example)

#### Generated Repository (`UserRepository.php`):

[](#generated-repository-userrepositoryphp)

```
