PHPackages                             mattb-it/larepo - 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. [Framework](/categories/framework)
4. /
5. mattb-it/larepo

ActiveLibrary[Framework](/categories/framework)

mattb-it/larepo
===============

A Laravel repository pattern implementation

0.5.0(10mo ago)421MITPHPPHP ^8.1CI passing

Since Oct 13Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/mattb-it/larepo)[ Packagist](https://packagist.org/packages/mattb-it/larepo)[ Docs](https://github.com/mattb-it/larepo)[ RSS](/packages/mattb-it-larepo/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (11)Used By (0)

Larepo - Laravel Repository
===========================

[](#larepo---laravel-repository)

[![Test build](https://github.com/mattb-it/larepo/actions/workflows/test.yml/badge.svg)](https://github.com/mattb-it/larepo/actions/workflows/test.yml/badge.svg)[![Latest version](https://camo.githubusercontent.com/4340cfd95870569c78974202e510b8b436683ff0d61dfad5227ec5efa281d5b9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6d617474622d69742f6c617265706f2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/4340cfd95870569c78974202e510b8b436683ff0d61dfad5227ec5efa281d5b9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6d617474622d69742f6c617265706f2e7376673f7374796c653d666c61742d737175617265)[![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)

📄 [Online Documentation](https://mattb.it/docs/larepo)

Introduction
------------

[](#introduction)

This package is designed to help developers organize their code by offering a simplified approach to implementing the Repository Pattern in Laravel. While it doesn’t follow the pattern in its purest form, it provides a practical solution that aligns well with Laravel’s architecture. Eloquent, being as powerful as it is, handles many database interactions behind the scenes, making a strict Repository Pattern not really useful. Instead, this package focuses on helping you structure your code more effectively without adding complexity.

With this package, you’ll find it easier to apply SOLID principles, search through your codebase for operations like querying, deleting, or saving models, and simplify the way you manage models by introducing DTOs (Data Transfer Objects). It’s especially useful for intermediate developers looking to build clean, maintainable applications while keeping things simple.

Getting started
---------------

[](#getting-started)

### Installation

[](#installation)

To install Larepo via Composer, run the following command:

```
composer require mattb-it/larepo
```

### Generate repository

[](#generate-repository)

Laravel projects typically include a `User` model by default. Let's generate a `UserRepository` using Larepo's artisan command:

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

This command will create a `UserRepository` class in `app/Repositories/UserRepository.php`:

```
