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. propaysystems/laravel-base-repositories

ActiveLibrary

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

Base elequent repositories with interface for common queries.

1.0.1(5mo ago)015.7k↓44.1%[2 PRs](https://github.com/PropaySystems/laravel-base-repositories/pulls)MITPHPPHP ^8.0|^8.1|^8.2|^8.3|^8.4|^8.5CI failing

Since Jan 9Pushed 5mo 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 1mo ago

READMEChangelog (10)Dependencies (12)Versions (19)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

49

—

FairBetter than 95% of packages

Maintenance70

Regular maintenance activity

Popularity26

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 90.5% 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 ~87 days

Recently: every ~201 days

Total

13

Last Release

175d ago

Major Versions

v0.0.11 → v1.0.02024-05-05

PHP version history (4 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

### 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 (57 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

Code StyleLaravel Pint

### 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

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)

PHPackages © 2026

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