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

ActiveLibrary

hsntngr/laravel-repository
==========================

Repository pattern for laravel applications

1.0.0(7y ago)14MITPHPPHP ^7.1

Since Feb 26Pushed 7y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Laravel Repository
==================

[](#laravel-repository)

**Simple repository pattern for laravel**

Keep clean your models and controllers

**Installation**

Install via composer.

`composer require hsntngr/laravel-repository`

Register repository service provider by adding into providers in config/app.php

```
'providers' => [
    // ...
    Hsntngr\Repository\ServiceProvider::class
];
```

Publish configuration file.

`php artisan vendor:publish --provider="Hsntngr\Repository\ServiceProvider::class" --tag="config"`

Then adjust your `App\Http\Controllers\Controller` class to use repository manager in all controllers. With Repository Manager you will able to instantiate any repository in anywhere

```
// ...
use Hsntngr\Repository\IRepositoryManager;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    protected $rm;

    public function __construct(IRepositoryManager $rm)
    {
        $this->rm = $rm;
    }
}
//Now you can easly instantiate a repository with $this->rm->{repositoryKey}
```

**Usage**

Use `make:repository Model` command to create new repository.

```
php artisan make:repository User

// app/Repositories/UserRepository.php

// Also you may define custom alias to retrieve repository. By default it uses lower case model name

php artisan make:repository PostTranslation --key=translate

```

Example

```
# PostController
public function show($id)
{
    $post = $this->rm->post->findPublishedPost($id);

    return view("posts.single",compact("post"));
}
```

If you want to cache results use `cache() & repository()` methods

```
public function show($id)
{
    $post = $this->rm->cache("post:".$id,3*60)
         ->repository("post",function($post) use ($id){
             return $post->findPublishedPost($id);
         });
    // if no minutes defined, it'll cache forever
    return view("posts.single",compact("post"));
}
```

Use `repository()` helper to instantiate any repository outside of the controller

```
repository("post")->findPublishedPost($id);
```

To list repositories, use `repository:list` command

```
php artisan repository:list

// post           ->  PostRepository
// user           ->  UserRepository
// comment        ->  CommentRepository

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Unknown

Total

1

Last Release

2632d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/489114a5dba3dcaebb2b5c7c146a484e519890d0421e5826b71319694e5348c2?d=identicon)[hsntngr](/maintainers/hsntngr)

---

Top Contributors

[![teomanofficial](https://avatars.githubusercontent.com/u/46353718?v=4)](https://github.com/teomanofficial "teomanofficial (6 commits)")

---

Tags

repository patternlaravel-repository

### Embed Badge

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

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

###  Alternatives

[torann/laravel-repository

Base repository implementation for Laravel

88497.8k2](/packages/torann-laravel-repository)[orkhanahmadov/eloquent-repository

Eloquent Repository for Laravel

2764.5k](/packages/orkhanahmadov-eloquent-repository)[suitmedia/laravel-cacheable

Decorate your repositories and make them cacheable

1237.7k](/packages/suitmedia-laravel-cacheable)

PHPackages © 2026

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