PHPackages                             phpsamurai/repository-pattern-generator - 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. phpsamurai/repository-pattern-generator

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

phpsamurai/repository-pattern-generator
=======================================

A simple Laravel package to implement and generate the repository pattern in your application.

v1.0.1(1y ago)039MITPHPPHP ^8.0

Since Nov 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/0x3b3fc/repository-pattern-generator)[ Packagist](https://packagist.org/packages/phpsamurai/repository-pattern-generator)[ RSS](/packages/phpsamurai-repository-pattern-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

Repository Pattern Generator
============================

[](#repository-pattern-generator)

This package provides a convenient way to generate repository patterns for your Laravel application. It helps to streamline the code structure and enhance maintainability by encapsulating data access logic.

Features
--------

[](#features)

- Automatically generates repository interfaces and implementations
- Supports dependency injection for easy testing
- Customizable stub files for fine-tuning the generated code

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require phpsamurai/repository-pattern-generator
```

Usage
-----

[](#usage)

### Register the Service Provider

[](#register-the-service-provider)

If you're using Laravel 5.5+, the package will auto-register the service provider. For earlier versions of Laravel, add the service provider in `config/app.php`:

```
'providers' => [
    // Other service providers...
    phpsamurai\RepositoryPatternGenerator\RepositoryPatternGeneratorServiceProvider::class,
],
```

### Publish the Configuration

[](#publish-the-configuration)

You can publish the configuration file with the following command:

```
php artisan vendor:publish
```

Then

```
RepositoryPatternGeneratorServiceProvider

```

### Generate a Repository

[](#generate-a-repository)

To generate a new repository, use the Artisan command:

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

For instance, to create a repository for a `User` model, you would execute:

```
php artisan make:repository User
```

### Custom Stubs

[](#custom-stubs)

You can customize the stub files used to generate the repository and interface. To do this, publish the stub files:

```
php artisan vendor:publish --provider="phpsamurai\RepositoryPatternGenerator\RepositoryPatternGeneratorServiceProvider" --tag="stubs"
```

Edit the stub files located in the `stubs/repository` directory to tailor them to your needs. The generator will use these modified stubs when creating new files.

Testing
-------

[](#testing)

To ensure the generated repository pattern integrates well with your Laravel application, you can write and run your tests using PHPUnit. Mocking dependencies is straightforward with the repository pattern, facilitating a cleaner and more maintainable test suite.

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

[](#contributing)

Contributions are welcome! Please follow these steps to contribute:

1. Fork the repository.
2. Create a new branch (`git checkout -b feature/your-feature-name`).
3. Commit your changes (`git commit -m 'Add some feature'`).
4. Push to the branch (`git push origin feature/your-feature-name`).
5. Open a pull request.

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE.md) file for details.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

Total

2

Last Release

532d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f22a01a2535b7524837de32d6037d2fb7040cc0ac0419b39ea23bcecab7786d1?d=identicon)[0x3b3fc](/maintainers/0x3b3fc)

---

Top Contributors

[![0x3b3fc](https://avatars.githubusercontent.com/u/65143991?v=4)](https://github.com/0x3b3fc "0x3b3fc (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[yajra/laravel-datatables-oracle

jQuery DataTables API for Laravel

4.9k33.8M338](/packages/yajra-laravel-datatables-oracle)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M157](/packages/orchestra-canvas)[illuminate/session

The Illuminate Session package.

9937.4M753](/packages/illuminate-session)[genealabs/laravel-changelog

A Laravel Nova tool.

55250.7k](/packages/genealabs-laravel-changelog)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40129.3k2](/packages/erlandmuchasaj-laravel-gzip)

PHPackages © 2026

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