PHPackages                             contracts/repositories - 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. contracts/repositories

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

contracts/repositories
======================

This package creates interfaces and repositories with resources and is capable of creating a model if it doesn't exist.

020PHP

Since Jan 29Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Muhammad-Yameen/laravel-repository-pattern)[ Packagist](https://packagist.org/packages/contracts/repositories)[ RSS](/packages/contracts-repositories/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-repository-pattern
==========================

[](#laravel-repository-pattern)

To Install.

```
    composer require contracts/repositories dev-master

```

Create a new service provider and add it to the list of providers.

```
    php artisan  make:provider RepositoryServiceProvider

```

Bind the repository and interface in the register function.

```
    $models = array(
        'CustomModel',
        'CustomModel2',
        'CustomModel3'
    );

    foreach ($models as $model) {
        $this->app->bind("App\Contracts\\{$model}RepositoryInterface", "App\Repositories\\{$model}Repository");
    }

```

add the new service provider to the providers array in the config/app.php file.

```
// ...other declared providers
App\Providers\RepositoryServiceProvider::class,

```

To create a repository and interface.

```
    php artisan make:repo Product

```

Or if you want to create a repository and interface along with resources.

```
    php artisan make:repo Product -r

```

It requires your permission to create a model if it doesn't exist.

```
    Product Model not found! Do you want to create?  [don't do it.]:
    [0] don't do it.
    [1] do it.
    > 1

    Model [/var/www/html/my_repo_project/app/Models/Product.php] created successfully.
    Interface [/var/www/html/my_repo_project/app/Contracts/ProductRepositoryInterface.php] created successfully.
    Repository [/var/www/html/my_repo_project/app/Repositories/ProductRepositories.php] created successfully.

```

Finally,

```
    use App\Contracts\ProductRepositoryInterface;

    class HomeController extends Controller
    {
        protected ProductRepositoryInterface $productRepository;
        public function __construct(ProductRepositoryInterface $productRepository)
        {
            $this->productRepository = $productRepository;
        }

        public function index()
        {
            $post  =  $this->productRepository->all();

            //code
        }
    }

```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7b04357469cdb7cb3f8b17d0b5e854a00369a13d70d10d6770cc0917a7f70fa7?d=identicon)[Muhammad-Yameen](/maintainers/Muhammad-Yameen)

---

Top Contributors

[![Muhammad-Yameen](https://avatars.githubusercontent.com/u/36126293?v=4)](https://github.com/Muhammad-Yameen "Muhammad-Yameen (3 commits)")

### Embed Badge

![Health badge](/badges/contracts-repositories/health.svg)

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

###  Alternatives

[doctrine/event-manager

The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.

6.0k526.1M158](/packages/doctrine-event-manager)[league/glide-laravel

Glide adapter for Laravel

1463.3M36](/packages/league-glide-laravel)[beste/json

A simple JSON helper to decode and encode JSON

4226.8M3](/packages/beste-json)[abbotton/ios-png-parser

A PHP-based tool for parsing IOS application icons in IPA files

2017.2k1](/packages/abbotton-ios-png-parser)[spatie/laravel-url-ai-transformer

Transform URLs and their content using AI

267.2k](/packages/spatie-laravel-url-ai-transformer)[mwdelaney/sage-fonts-preload

Automatically preload fonts from the Sage mix manifest

188.5k](/packages/mwdelaney-sage-fonts-preload)

PHPackages © 2026

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