PHPackages                             maamun7/serpository - 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. maamun7/serpository

ActiveLibrary

maamun7/serpository
===================

Generate service, repositories and inject them by an artisan command for scalable laravel application.

1147PHP

Since Apr 16Pushed 4y ago1 watchersCompare

[ Source](https://github.com/maamun7/serpository)[ Packagist](https://packagist.org/packages/maamun7/serpository)[ RSS](/packages/maamun7-serpository/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (3)Used By (0)

Serpository (Service Repository Pattern in Laravel)
---------------------------------------------------

[](#serpository-service-repository-pattern-in-laravel)

[![License](https://camo.githubusercontent.com/19d8f7e69f2dd10635774d16d3343c4014b0183529d50595632657803ca9b54b/68747470733a2f2f706f7365722e707567782e6f72672f6d61616d756e372f736572706f7369746f72792f6c6963656e73652e737667)](https://packagist.org/packages/maamun7/serpository)[![Total Downloads](https://camo.githubusercontent.com/8eed74c25267e690c6f306db567e79f7eb5a00be9704ef510e225b6ecf7c96b9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61616d756e372f736572706f7369746f72792e737667)](https://packagist.org/packages/maamun7/serpository)

Many of us *Laravel* developers like to use **Service-Repository** pattern in *Laravel* applications to develop scalable application. So creating these **Service**, **Repository** classes and inject them manually is very time-consuming as well as annoying at times.

I faced this issue several times, that is why I developed this package to make my task easier. I strongly believe that many of us having this issue. For them, I decided to make it public.

This package provides the facility to make **service &amp; repository** together and inject them by an artisan command. In addition to this, people also will be able to make **service** or **repository** individually. More details are given in features section.

### Requirement

[](#requirement)

This package requires php version &gt;=7.4 and Laravel version &gt;=8

### Installation

[](#installation)

1. Install this packages via composer:

```
composer require maamun7/serpository

```

2. Add the **Serpository** Service Provider to the providers array in config/app.php

```
Maamun7\Serpository\SerpositoryServiceProvider::class,

```

### Features

[](#features)

1. Create Service

```
php artisan make:service User

```

If there is no `Services` directory inside `app`, firstly the above command will create that directory and then will make a `Service` class by the provided name with `Service` suffix inside this created `Services` directory. E.g: `UserService`.

2. Create Repository

```
php artisan make:repo User  OR  php artisan make:repository User

```

If there is no `Repositories` directory inside `app`, firstly the above command will create that directory and then will make a `Repository` class by the provided name with `Repository` suffix inside that created `Repositories/Eloquents` directory. E.g: `UserRepository` .

Besides, the Repository will have an Injected `Interface` with a separate `Interfaces` directory inside the Repository.

Moreover, this command will search a model inside `app\Models` directory by provided repository name and adding some suffix (e.g: suppose the provided name is User then it will search by User, Users, UserModel &amp; User\_Model). If there is a model with those names it will inject into the Repository; otherwise it will inject a model with the provided base name.

3. Create Service &amp; Repository with the same name

```
php artisan make:service User --r

```

Flag `--r` will give scope to create a Service as well as a Repository together with the same base name. In addition to this, this created repository will be injected into this service automatically.

4. Create Service &amp; Repository with the different name

```
php artisan make:service User --r --repo=MyUser

```

The above command will create a Service with the name `UserService` &amp; a Repository named `MyUserRepository`. This repository also will be injected into this service automatically.

### How does it work with Controller?

[](#how-does-it-work-with-controller)

#### The following example shows how it works with controller.

[](#the-following-example-shows-how-it-works-with-controller)

```

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Services\UserService;

class UserController extends Controller
{
    protected $userService;

    /**
     * @param UserService $userService
     */
    public function __construct(UserService $userService)
    {
        $this->userService = $userService;
    }

    public function index()
    {
        $users = $this->userService->getAll();
    }
}

```

### License

[](#license)

**Serpository** is a free software distributed under the terms of the MIT license.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0075cc3ef2c79c8947a9ec80ae0a9ecd7e459536d8c17131741dd54af0becca9?d=identicon)[maamun7](/maintainers/maamun7)

---

Top Contributors

[![maamun7](https://avatars.githubusercontent.com/u/5427055?v=4)](https://github.com/maamun7 "maamun7 (33 commits)")

### Embed Badge

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

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

PHPackages © 2026

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