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

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

propaysystems/laravel-base-repositories
=======================================

Base elequent repositories with interface for common queries.

v1.0.2(2mo ago)017.2k↓79.2%[2 PRs](https://github.com/PropaySystems/laravel-base-repositories/pulls)MITPHPPHP ^8.1|^8.2|^8.3|^8.4|^8.5CI passing

Since Jan 9Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/PropaySystems/laravel-base-repositories)[ Packagist](https://packagist.org/packages/propaysystems/laravel-base-repositories)[ Docs](https://github.com/propaysystems/laravel-base-repositories)[ RSS](/packages/propaysystems-laravel-base-repositories/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)Dependencies (25)Versions (20)Used By (0)

[![Propay Systems](https://camo.githubusercontent.com/c08ade3d657e755eb9e34f9f3fd8fa159e43d55365d3375faf5bf6257dad19ad/68747470733a2f2f6433323478346577337936746e6e2e636c6f756466726f6e742e6e65742f7061636b616765732f62616e6e6572732f70726f70617973797374656d732d626173652d7265706f7369746f726965732e706e67)](https://camo.githubusercontent.com/c08ade3d657e755eb9e34f9f3fd8fa159e43d55365d3375faf5bf6257dad19ad/68747470733a2f2f6433323478346577337936746e6e2e636c6f756466726f6e742e6e65742f7061636b616765732f62616e6e6572732f70726f70617973797374656d732d626173652d7265706f7369746f726965732e706e67)

Base elequent repositories with interfaces for common queries.
==============================================================

[](#base-elequent-repositories-with-interfaces-for-common-queries)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d75a4403051d91b36c09e13b54092be92535e946c8813cefde686bcb68b54942/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70726f70617973797374656d732f6c61726176656c2d626173652d7265706f7369746f726965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/propaysystems/laravel-base-repositories)[![GitHub Tests Action Status](https://camo.githubusercontent.com/f7006dec5cfc47e3d8535e832f2540e2b048254000cd4fb2e25dcdf33411efdc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70726f70617973797374656d732f6c61726176656c2d626173652d7265706f7369746f726965732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/propaysystems/laravel-base-repositories/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a5f6f6c687ebb89e1522812c5d96ed2354130ccfd980a08240e8f3b90facf6e0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70726f70617973797374656d732f6c61726176656c2d626173652d7265706f7369746f726965732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/propaysystems/utilities/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/7fcab2a24308a3f0b24839a7db69e42a8917a596b8bb0f6de7df10434c2bd169/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70726f70617973797374656d732f6c61726176656c2d626173652d7265706f7369746f726965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/propaysystems/laravel-base-repositories)

UNDER DEVELOPMENT AND TESTING - WE WILL ADD PROPER DOCUMENTATION WITH v1 STABLE RELEASE
=======================================================================================

[](#under-development-and-testing---we-will-add-proper-documentation-with-v1-stable-release)

This is the base classes &amp; helper commands for the repository pattern we use. In your own repository classes you have to extend the BaseRepository and implement your custom interface. In your custom interface you have to extend the BaseRepositoryInterface. This will give you a collection of commonly used queries and function that you don't need to duplicate each time.

```
class AddressRepository extends BaseRepository implements AddressRepositoryInterface
```

```
interface AddressRepositoryInterface extends BaseRepositoryInterface
```

Requirements
------------

[](#requirements)

PHP 8.0+
Laravel 8+

Version Compatibility
---------------------

[](#version-compatibility)

LaravelBaseRepositories8.x0.0.79.x0.0.310.x0.0.8Installation
------------

[](#installation)

You can install the package via composer:

```
composer require propaysystems/laravel-base-repositories
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-base-repositories-config"
```

Configuration
=============

[](#configuration)

We create the service and repositories in the app folder of laravel to make use of laravels auto loading functionality.

Service
-------

[](#service)

The default path for createing services will be in the `App\Services` folder. If the folder does not exist it will be created.

If you want to overwrite default path for the service you can add a `ENV` variable and specify your custom path.

```
BASE_SERVICE_PATH="App\MyServiceFolder"
```

The base name that will be appended to the class that is created by default, it will append `Service`. So if you create a `User -s`service the file that gets created will be `UserService`

```
APPEND_SERVICE_NAME="Service"
```

Repository
----------

[](#repository)

The default path for createing repositories will be in the `App\Repositories` folder. If the folder does not exist it will be created.

If you want to overwrite default path for the repository you can add a `ENV` variable and specify your custom path.

```
BASE_REPOSITORY_PATH="App\MyRepositoryFolder"
```

The base name that will be appended to the class that is created by default, it will append `Repository`. So if you create a `User -r`service the file that gets created will be `UserRepository` &amp; `UserRepositoryInterface`

```
APPEND_REPOSITORY_NAME="Repository"
```

Usage
=====

[](#usage)

Creating a Service
------------------

[](#creating-a-service)

The service class is where all the domain logic will be created. This makes it easier to reuse business logic in the controllers, API, commands etc

1. Creating a service class:

```
php artisan base:create Users/User --service
or
php artisan base:create Users/User -s
```

Running this command will create a new service class in the `App\Services\` folders.

The rule is to split every service into its own related folders so the above command will actually create a file in:

- `App\Services\Users\UserService.php`

### Injecting a Repository

[](#injecting-a-repository)

> ❕ Remember to dependancy inject your repositories you want to use into the `__construct` method of your service like the example below.

```
PHP 8.1 & above using constructor promotion
public function __construct(
    protected UserRepositoryInterface $userRepository,
)
{}

or

PHP 8.0 & below
protected UserRepositoryInterface $userRepository;

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

Creating a Repository
---------------------

[](#creating-a-repository)

1. Creating a repository class:

```
php artisan base:create Users/User --repository --model=App/Models/Users/User
or
php artisan base:create Users/User -r --model=App/Models/Users/User
```

Running this command will create a repository class with its related interface in the `App\Repositories` &amp; `App\Repository\UserRepository\Interfaces` folder. Specifying the model with auto link the relevant model to the repository. In this case the User model will be added to the construct methof of the repository.

Same as the service class the rule is to split each repository into its own related folders so the above command will create files in:

- `App\Repositories\Users\UserRepositories.php`
- `App\Repositories\Users\Interfaces\UserRepositoriesInterface.php`

This will also try create and register the class and interface in laravel.

> ❕ These command flags can be combined `-s -r` so that the related service and repository classes be created in one command.

### First Repository

[](#first-repository)

After creating your first repository a `RepositoryServiceProvider.php` file will automatically be created in your `App\Providers` folder. You will need to add the repository provider file to your `config/app.php` under the `providers` section. This will tell laravel that you are adding repositories and linking interfaces to them and they be autoloaded.

```
...

/*
 * Package Service Providers...
 */
App\Providers\RepositoryServiceProvider::class,

...
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Ettienne Louw](https://github.com/PropaySystems)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance86

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 90.6% 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 ~92 days

Recently: every ~237 days

Total

14

Last Release

72d ago

Major Versions

v0.0.11 → v1.0.02024-05-05

PHP version history (5 changes)0.0.1PHP ^8.1

v0.0.9PHP ^8.0|^8.1|^8.2

v1.0.0PHP ^8.0|^8.1|^8.2|^8.3

1.0.1PHP ^8.0|^8.1|^8.2|^8.3|^8.4|^8.5

v1.0.2PHP ^8.1|^8.2|^8.3|^8.4|^8.5

### Community

Maintainers

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

---

Top Contributors

[![ettiennelouw](https://avatars.githubusercontent.com/u/1754421?v=4)](https://github.com/ettiennelouw "ettiennelouw (58 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

elequentlaravelpatternlaravelPropaySystemslaravel-base-repositories

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/propaysystems-laravel-base-repositories/health.svg)

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

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M101](/packages/dedoc-scramble)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

213421.2k2](/packages/wnx-laravel-backup-restore)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17558.6k](/packages/lacodix-laravel-model-filter)

PHPackages © 2026

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