PHPackages                             bigpaulie/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. bigpaulie/repository

ActiveLibrary

bigpaulie/repository
====================

An implementation of the repository patter for Laravel Framework

v2.0(6y ago)1365MITPHPPHP ^7.2CI failing

Since Mar 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/bigpaulie/repository)[ Packagist](https://packagist.org/packages/bigpaulie/repository)[ Docs](https://github.com/bigpaulie/repository)[ RSS](/packages/bigpaulie-repository/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (5)Versions (5)Used By (0)

Repository
==========

[](#repository)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6fba6fbd322365e401da80a221eea91df738f1ded1e2af9b0e9612eb80c77f80/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6269677061756c69652f7265706f7369746f72792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bigpaulie/repository)[![Total Downloads](https://camo.githubusercontent.com/a1fb6d213294098d5cc193efb89321f0b48240e26d449d092c4ee614884b2178/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6269677061756c69652f7265706f7369746f72792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bigpaulie/repository)[![Build Status](https://camo.githubusercontent.com/7030d8f3b90f48886c3ba92bd58d31d505542025224a39c28016b2d4d3d6dce0/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6269677061756c69652f7265706f7369746f72792f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/bigpaulie/repository)

A repository pattern implementation for Laravel Framework

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

[](#installation)

Via Composer

```
$ composer require bigpaulie/repository
```

Publish the configuration file

```
$ php artisan vendor:publish --provider=bigpaulie\\repository\\RepositoryServiceProvider --tag=repository.config
```

Compatibility
-------------

[](#compatibility)

package versionlaravel version2.x6.9 or newer1.x5.xUsage
-----

[](#usage)

A repository class is any class that extends bigpaulie\\repository\\AbstractRepository

The general rule of thumb is that your repository should have the same name as your model by with a suffix of "Repository".

Let's say we have the following case, we have a model named Person, than the repository class should be named PersonRepository

```
class PersonRepository extends AbstractRepository {}
```

Generating repositories using artisan commands
----------------------------------------------

[](#generating-repositories-using-artisan-commands)

You can generate a repository for your model using the provided artisan command

```
php artisan repository:generate Person
```

The above command will generate a repository class called PersonRepository.

### Find

[](#find)

Find a specific resource by it's ID

```
/** @var PersonRepository $repository */
$repository = new PersonRepository();

/** @var Person|null $person */
$person = $repository->find(1);
```

### Get all

[](#get-all)

Get all results for this resource

```
/** @var PersonRepository */
$repository = new PersonRepository();

/** @var Illuminate\Database\Eloquent\Collection|Person[] */
$persons = $repository->all();
```

### Create

[](#create)

Create's a new resource and return the database object, if your model doesn't allow mass assigning of attributes, use `false` as the second parameter.

```
/** @var PersonRepository $repository */
$repository = new PersonRepository();

/** @var Person $person */
$person = $repository->create([
    'name' => 'Popescu Ion',
    'age' => 30
]);
```

### Update

[](#update)

Update a specific resource by it's ID, you can also pass a model instance as a second parameter.

```
/** @var PersonRepository $repository */
$repository = new PersonRepository();

/** @var Person $person */
$person = $repository->update([
    'name' => 'Popescu Marin',
    'age' => 33
], 1);
```

### Delete

[](#delete)

Delete a specific resource by it's ID, you can also force delete by passing `true` as the second parameter.

```
/** @var PersonRepository $repository */
$repository = new PersonRepository();

try {
    /** @var Person $person */
    $person = $repository->delete(1);
} catch (RepositoryException $exception) {
    // do something if operation fails
}
```

Using helper function
---------------------

[](#using-helper-function)

You can use the helper function by providing the FQDN of a repository or a model.

If a repository exists for a given model, an instance of the repository is returned otherwise an abstract repository is returned allowing you to preform all the builtin CRUD functionality.

The Person model has a PersonRepository

```
/** @var PersonRepository $person */
$personRepository = repository(PersonRepository::class);

/** @var PersonRepository $person */
$personRepository = repository(Person::class);
```

The Dog model doesn't have a repository

```
/** @var bigpaulie\repository\Repository $dog */
$repository = repository(Dog::class);
```

### Learn more

[](#learn-more)

Check out our [wiki](https://github.com/bigpaulie/repository/wiki)

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ ./vendor/bin/phpunit -c phpunit.xml
```

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits
-------

[](#credits)

- [Paul Purcel](https://github.com/bigpaulie)

License
-------

[](#license)

license. Please see the [license file](license.md) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~156 days

Total

3

Last Release

2297d ago

Major Versions

v1.0.1 → v2.02020-01-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/1706d209e8e01305b6823045fac6d363e149abd14a4bd20397d237ea1107a2b4?d=identicon)[bigpaulie](/maintainers/bigpaulie)

---

Top Contributors

[![bigpaulie](https://avatars.githubusercontent.com/u/5903753?v=4)](https://github.com/bigpaulie "bigpaulie (12 commits)")

---

Tags

laravelrepository

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bigpaulie-repository/health.svg)

```
[![Health](https://phpackages.com/badges/bigpaulie-repository/health.svg)](https://phpackages.com/packages/bigpaulie-repository)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
