PHPackages                             repository/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. [Database &amp; ORM](/categories/database)
4. /
5. repository/repository

ActiveLibrary[Database &amp; ORM](/categories/database)

repository/repository
=====================

Repository classes for communication with database

v1.1.1(6y ago)04MITPHPPHP ^7.0CI failing

Since Mar 16Pushed 6y ago1 watchersCompare

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

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

Repository package in development....

What is this?
-------------

[](#what-is-this)

This package is powerful and fully customizable DB model repository for storing a queries.

How to intall package?
----------------------

[](#how-to-intall-package)

```
composer require repository/repository

```

Make new repository with artisan command
----------------------------------------

[](#make-new-repository-with-artisan-command)

```
php artisan make:repository ExampleRepository

```

This will automaticaly create `ExampleRepository` facade and `ExampleServiceContainer` where you write your queries. This means that service container will call `Example` model. If `Example` model don't exist, don't wory, artisan will create it instead of you.

But if you want to use another model, you can require that.

```
php artisan make:repository ExampleRepository --model NewModel

```

How to access methods from `ServiceContainer`?
----------------------------------------------

[](#how-to-access-methods-from-servicecontainer)

It's simple, just call your `Repository` facade.

```
ExampleRepository::simpleMethod();
```

Now, let's create a simple method in `ExampleServiceContainer`.

```
public function simpleMethod()
{
    // use buildQuery() to prepare your query for execution
    // $builder is instance of \Illuminate\Database\Eloquent\Builder so you can
    // regularly use builder's methods whatever you want.
    $this->buildQuery(function (Builder $builder) {
        return $builder->where('destination', 'San Diego')
                       ->take(20);
    });

    // this actually execute your query
    // in this place you can use any 'end point' method from Laravel builder
    // like count(), max(), findOrFail(), etc...
    return $this->get();
}
```

Of cource, there's the old-school query.

```
public function simpleMethod()
{
    return $this->executeRaw("SELECT * FROM examples LIMIT 20");
}
```

`Repository` package has built-in query caching system so you can easily use it. Let's try it (you do not need all these methods at once, use only the ones you need).

```
// remember result for a globally defined time or set your custom time
$this->remember(?duration:);

// remember results forever
$this->rememberForever();

// if you have changeable caching state, this is ideally for you
$this->useCache(cache_state:, ?remember_type:);

// is you not satisfied with global settings, you can change it any time
// keep it mind this only affect locally
$this->store('cache_engine');
```

Well that's nice but where is all that 'customizable'?
------------------------------------------------------

[](#well-thats-nice-but-where-is-all-that-customizable)

All of these methods above you can use in fly, and more. Look.

```
ExampleRepository::remember()->simpleMethod();

// change cache engine in fly
ExampleRepository::store('redis')->remember(3600)->simpleMethod();
```

Hm, `simpleMethod` use `get()` to retrieve results but I need take max salary, is that possible? Of course it is possible. Look.

```
ExampleRepository::requireBuilder()->simpleMethod()->max('salary');
```

> *Note: keep in mind that `requireBuilder()` exclude all repository benefits (like caching).*

That's all?
-----------

[](#thats-all)

Of cource it is not. Repository gives you a possibility to modify queries on fly.

```
ExampleRepository::orderBy('hire_date', 'desc')->simpleMethod();
```

> *Note: this not overriding query in `simpleMethod()`. If you want to override, then require a builder.*

Repository have a possibility to dynamic handle all Laravel query builder methods. You can even write the entire query in fly and cache the result.

```
ExampleRepository::rememberForever()->where('destination', 'San Diego')->get();
```

Only sky is the limit. Enjoy.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Total

3

Last Release

2245d ago

### Community

Maintainers

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

---

Top Contributors

[![uros196](https://avatars.githubusercontent.com/u/10147342?v=4)](https://github.com/uros196 "uros196 (17 commits)")

---

Tags

database-querieslaravelphp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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