PHPackages                             okipa/laravel-base-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. okipa/laravel-base-repository

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

okipa/laravel-base-repository
=============================

An abstract base repository with predefined common features.

1.1.9(7y ago)15032MITPHPPHP &gt;=7.0

Since May 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Okipa/laravel-base-repository)[ Packagist](https://packagist.org/packages/okipa/laravel-base-repository)[ Docs](https://github.com/Okipa/laravel-base-repository)[ RSS](/packages/okipa-laravel-base-repository/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (4)Versions (21)Used By (0)

laravel-base-repository
=======================

[](#laravel-base-repository)

An abstract base repository with predefined common features.

[![Source Code](https://camo.githubusercontent.com/9665b0ad9c594b24d915247dd5a68975d20029d1ce76b6831445cc97eb32932d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d6f6b6970612f6c61726176656c2d2d6d6f64656c2d2d626173652d2d7265706f7369746f72792d626c75652e737667)](https://github.com/Okipa/laravel-base-repository)[![Latest Version](https://camo.githubusercontent.com/f2b845efda0e5c4c2e50e93e622a0bd2e6ed55bbd8934f65cfc368057714b726/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6f6b6970612f6c61726176656c2d626173652d7265706f7369746f72792e7376673f7374796c653d666c61742d737175617265)](https://github.com/Okipa/laravel-base-repository/releases)[![Total Downloads](https://camo.githubusercontent.com/d7a809716b9a69dea9ae65d2dac27bcc5115e73e3583b6ea0756100fa72320a0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6b6970612f6c61726176656c2d626173652d7265706f7369746f72792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/okipa/laravel-base-repository)[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](https://opensource.org/licenses/MIT)[![Build Status](https://camo.githubusercontent.com/3cf2c0a1f7de594444b17dd8c4508be7fa057c1fb590593b87ce806e131c96f0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4f6b6970612f6c61726176656c2d626173652d7265706f7369746f72792f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Okipa/laravel-base-repository/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/825b51a20d14742d3632ae932a924ad26096c20670722437642f5fe4ba4ec064/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4f6b6970612f6c61726176656c2d626173652d7265706f7369746f72792f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Okipa/laravel-base-repository/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0e8c7514ccc9ab4ad43c2959fd343b75029f6ed1259177f04aec62719e06f569/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4f6b6970612f6c61726176656c2d626173652d7265706f7369746f72792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Okipa/laravel-base-repository/?branch=master)

---

Before starting
---------------

[](#before-starting)

The repository pattern has several objectives :

- Encourage development good practices (separation of concerns, code reusability, ...)
- Improve code testability

Before using this package, you should be familiar with the repository pattern, and especially with its Laravel implementation.
You can know more about it by reading the several articles you'll can find on Internet about this.
Here is one among others : .

**Notes :**

- This base repository does **NOT** allow you to manipulate the model : it can sometimes be tempting to directly manipulate the model from your controller but this is not recommended and recognized as a bad practice.
- You should always fill your repositories interfaces : it can avoid huge errors on your projects.
- The provided methods are shortcuts to avoid you to declare them in your own base repository or in several repositories. Keep in mind that they only are pre-defined methods and that you should declare new methods in your repositories if they does not fit with your needs.

---

Installation
------------

[](#installation)

The repository pattern setup is not complicated but requires several steps to be accomplished.
Follow them one by one :

- Install the package with composer :

```
composer require okipa/laravel-base-repository
```

- Create a `app/Repositories` directory where you will store your different project repositories.
- Create your `app/Repositories/BaseRepositoryInterface.php` interface and your `app/Repositories/BaseRepository.php` abstract class :

```
