PHPackages                             akunbeben/laravository - 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. akunbeben/laravository

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

akunbeben/laravository
======================

Simplify Repository Pattern for Laravel.

1.0.3(5y ago)16149MITPHPPHP ^7.3|^8.0

Since Apr 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/akunbeben/laravository)[ Packagist](https://packagist.org/packages/akunbeben/laravository)[ Fund](https://saweria.co/akunbeben)[ RSS](/packages/akunbeben-laravository/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (5)Used By (0)

[![](https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg)](https://laravel.com)

Laravository - Repository Pattern for Laravel
=============================================

[](#laravository---repository-pattern-for-laravel)

Simplified Repository pattern implementation in Laravel.

Requirement
-----------

[](#requirement)

- Laravel 8.x

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

[](#installation)

Execute the following command to get the latest version of the package:

```
composer require akunbeben/laravository

```

Execute the following command to create the RepositoryServiceProvider:

```
php artisan repository:provider

```

Go to the `config/app.php` and add this `App\Providers\RepositoryServiceProvider::class` to your providers config:

The `RepositoryServiceProvider` will work as Dependency Injection.

```
'providers' => [
  ...
  App\Providers\RepositoryServiceProvider::class,
],
```

Methods
-------

[](#methods)

Akunbeben\\Laravository\\Repositories\\Interfaces

- getAll();
- getById($id, $relations = null)
- create($attributes)
- update($id, $attributes)
- delete($id)

Usage
-----

[](#usage)

### Create a new Repository

[](#create-a-new-repository)

To create repository, you just need to run like this:

```
php artisan make:repository User

```

You can also add `-m` or `--model` option to generate the Model:

```
php artisan make:repository User -m

```

So you don't need to create Model manually.

You can find out the generated files under the App\\Repositories\\ folder:

- Repository: App\\Repositories\\Eloquent\\
- Interface: App\\Repositories\\Interfaces\\

#### UserRepository.php

[](#userrepositoryphp)

```
namespace App\Repositories\Eloquent;

use Akunbeben\Laravository\Repositories\Eloquent\BaseRepository;

use App\Repositories\Interfaces\UserRepositoryInterface;
use App\Models\User;

class UserRepository extends BaseRepository implements UserRepositoryInterface
{
  protected $model;

  /**
   * Your model to use the Eloquent
   *
   * @param User $model
   */
  public function __construct(User $model)
  {
    $this->model = $model;
  }
}
```

#### UserRepositoryInterface.php

[](#userrepositoryinterfacephp)

```
namespace App\Repositories\Interfaces;

interface UserRepositoryInterface
{

}
```

After you created the repositories. you need to register your Class and Interface in the `RepositoryServiceProvider.php`

```
...
class RepositoryServiceProvider extends ServiceProvider
{
  ...
  public function register()
  {
    ...
    $this->app->bind(UserRepositoryInterface::class, UserRepository::class);
  }
}
```

Now you can implement it to your Controller. Like this example below:

```
namespace App\Http\Controllers;

use App\Repositories\Interfaces\UserRepositoryInterface;

class UserController extends Controller
{
  protected $userRepository;

  public function __construct(UserRepositoryInterface $userRepository) {
    $this->userRepository = $userRepository;
  }
}
```

So your Controller will much cleaner and much shorter.

```
class UserController extends Controller
{
  protected $userRepository;

  public function __construct(UserRepositoryInterface $userRepository) {
    $this->userRepository = $userRepository;
  }

  ...

  public function store(SomeFormRequest $request)
  {
    return $this->userRepository->create($request->validated());
  }
}
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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 ~7 days

Total

4

Last Release

1835d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f20c23b63b8a555ef973a720366095466ef8eb82e25a2703a871c62d4236f79d?d=identicon)[akunbeben](/maintainers/akunbeben)

---

Top Contributors

[![akunbeben](https://avatars.githubusercontent.com/u/46495960?v=4)](https://github.com/akunbeben "akunbeben (20 commits)")

---

Tags

hacktoberfestimplementationlaravelpackagephprepositoryrepository-pattern

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/akunbeben-laravository/health.svg)

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

PHPackages © 2026

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