PHPackages                             hpolthof/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. [Framework](/categories/framework)
4. /
5. hpolthof/repository

ActiveLibrary[Framework](/categories/framework)

hpolthof/repository
===================

A simple Repository Pattern implementation for Laravel 5

1.0.0(6y ago)04PHP

Since Aug 13Pushed 6y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (2)Used By (0)

Repositories for Laravel
========================

[](#repositories-for-laravel)

This is a package that has a simple implementation of a repository pattern for use with Eloquent.

How to use?
-----------

[](#how-to-use)

Install the package with composer in your project.

```
composer require hpolthof/repository
```

### Generator command

[](#generator-command)

Now you can create repositories with a new generator command

```
php artisan make:repository {modelName}
```

This will create a new repository in a Repositories directory within the app directory.

### Model Generator

[](#model-generator)

This package will also extend the `make:model` generator. When this generator is called with the parameter `--all` or `-a` and `--repository` or `-o` a repository will also be generated.

The Repository
--------------

[](#the-repository)

The repository is an empty class that extends `Hpolthof\Laravel\Repository\Repository` which implements `Hpolthof\Laravel\Repository\Contracts\RepositoryInterface`. This interface looks like:

```
interface RepositoryInterface
{
    public function all(array $columns = ['*']): Collection;
    public function list(string $orderByColumn, string $orderBy = 'desc', array $with = [], array $columns = ['*']): Collection;
    public function builder(Closure $builder, array $columns = ['*']): Collection;

    public function create(array $data): ?Model;
    public function update(array $data, $id): bool;
    public function delete($id): bool;

    public function find($id, array $columns = ['*']): ?Model;
    public function findBy(string $field, $value, array $columns = ['*']): ?Model;
}
```

### Automatic Model Detection

[](#automatic-model-detection)

The repository will try to detect the associated Eloquent model that should be used. If the model is named `{ModelName}Repository`, the model will automatically be used.

#### Setting the model manually

[](#setting-the-model-manually)

If the model cannot be detected or if you want to use another name, the `$modelName`property should be set. This can be done as in the example below:

```
use App\Demo;

class DemoRepository extends Repository {
    protected $modelName = Demo::class;
}
```

### Usage in controllers

[](#usage-in-controllers)

In a controller you can instantiate a repository using dependency injection. See the example below:

```
class DemoController extends Controller {
    protected $repository;

    public function __construct(DemoRepository $repository)
    {
        $this->repository = $repository;
    }
}
```

Disclaimer
----------

[](#disclaimer)

This package is used for internal development, but published for public use. Obviously this software comes *as is*, and there are no warranties or whatsoever.

If you like the package it is always appreciated if you drop a message of gratitude! ;-)

The package was build by: Paul Olthof

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

2512d ago

### Community

Maintainers

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

---

Top Contributors

[![hpolthof](https://avatars.githubusercontent.com/u/1415623?v=4)](https://github.com/hpolthof "hpolthof (1 commits)")

### Embed Badge

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

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

###  Alternatives

[laravel/octane

Supercharge your Laravel application's performance.

4.0k24.7M205](/packages/laravel-octane)[unopim/unopim

UnoPim Laravel PIM

10.5k2.2k](/packages/unopim-unopim)[code16/sharp

Laravel Content Management Framework

79062.6k7](/packages/code16-sharp)[nasirkhan/laravel-starter

A CMS like modular Laravel starter project.

1.4k2.7k](/packages/nasirkhan-laravel-starter)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21313.7k3](/packages/ecotone-laravel)[codewithdennis/larament

Larament is a time-saving starter kit to quickly launch Laravel 13.x projects. It includes FilamentPHP 5.x pre-installed and configured, along with additional tools and features to streamline your development workflow.

3911.7k](/packages/codewithdennis-larament)

PHPackages © 2026

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