PHPackages                             tgalfa/reposervice - 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. [CLI &amp; Console](/categories/cli)
4. /
5. tgalfa/reposervice

AbandonedArchivedLibrary[CLI &amp; Console](/categories/cli)

tgalfa/reposervice
==================

Generate repository, service and interface files for Repository-Service Pattern.

v1.2.5(2y ago)0204MITPHP

Since Feb 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/tgalfa/reposervice)[ Packagist](https://packagist.org/packages/tgalfa/reposervice)[ Docs](https://github.com/tgalfa/reposervice)[ RSS](/packages/tgalfa-reposervice/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (14)Used By (0)

RepoService Generator
=====================

[](#reposervice-generator)

RepoService Generator is a Laravel package that generates service and interface files for [Repository-Service Pattern](https://www.vodovnik.com/2015/08/26/repository-and-services-pattern-in-a-multilayered-architecture/).

- The repository is a layer between the domain and data layers of your application to perform CRUD operations.
- A service applies the business logic of your application. It simply performs the a set task using the information provided, using any repositories or other classes you have created outside of the service.

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

[](#installation)

You can install the package via composer:

```
composer require tgalfa/reposervice --dev
```

You can publish the config file with:

```
php artisan vendor:publish --tag="reposervice-config"
```

You can set the Repository and Service folders path and namespaces in the config file:

```
return [
    ...
    'namespaces' => [
        ....
        'repositories' => 'App\Repositories',
        'repositoryContracts' => 'App\Repositories\Contracts',

        'services' => 'App\Services',
        'serviceContracts' => 'App\Services\Contracts',
        ....
    ],
    ....
    'paths' => [
        'repositories' => 'app/Repositories/',
        'repositoryContracts' => 'app/Repositories/Contracts/',

        'services' => 'app/Services/',
        'serviceContracts' => 'app/Services/Contracts/',
    ],
    ....
];
```

All generated Services and Repositories extend an abstract class. If you do not want to use the default AbstractMainService and AbstractMainRepository classes you can create your own and use those instead. Update your `reposervice` config:

```
return [
    ...
    'namespaces' => [
        ....
        'main' => [
            'repository' => 'App\Repositories',
            'repositoryContract' => 'App\Repositories\Contracts',

            'service' => 'App\Services',
            'serviceContract' => 'App\Services\Contracts',
        ],
    ],
    ....
    'main' => [
        'repository' => 'MyAbstractMainRepository',
        'repositoryContract' => 'MyMainRepositoryInterface',

        'service' => 'MyAbstractMainService',
        'serviceContract' => 'MyMainServiceInterface',
    ],
];
```

Usage
-----

[](#usage)

Before using the generate commdand you should customize `config/reposervice.php` for your own use. You can simply use `reposervice:generate` and pass your model class as a parameter:

```
php artisan reposervice:generate Post
```

Available Methods
-----------------

[](#available-methods)

The following methods are available:

##### tgalfa\\RepoService\\Services\\Contracts\\MainServiceInterface

[](#tgalfareposerviceservicescontractsmainserviceinterface)

```
    public function getModel();

    public function get(array $columns = ['*'], array $scopes = []]);

    public function paginate(
        int $perPage,
        array $columns = ['*'],
        array $scopes = []
    );

    public function getById(int $id, array $columns = ['*']);

    public function store(array $data, array $scopes = []);

    public function update(Model $model, array $data, array $scopes = []);

    public function updateOrCreate(array $attributes, array $data, array $scopes = []);

    public function delete(Model $model);
```

### Example usage

[](#example-usage)

Get Active Posts with the category\_id = 5:

```
$post = $this->postService->get(
    ['id', 'title', 'description'],
    ['isActive', 'byCategory' => 5]
);
```

You need to create the relevent scopes in your Model class to use them. Example:

```
public function scopeIsActive(Builder $query)
{
    return $query->where('active', 1);
}
public function scopeByCategory(Builder $query, int $categoryId)
{
    return $query->where('category_id', $categoryId);
}
```

Get Paginated Posts:

```
$post = $this->postService->paginate(
    8,
    ['id', 'title', 'description'],
);
```

Create a new Post in repository:

```
$post = $this->postService->store($request->all());
```

Update existing Post:

```
$post = $this->postService->update($post, $request->all());
```

Update existing Post if all the given attributes matches or create a new Post:

```
$post = $this->postService->updateOrCreate(
    ['slug' => $request->slug],
    $request->all()
);
```

Delete Post:

```
$post = $this->postService->delete($post);
```

##### tgalfa\\RepoService\\Services\\Contracts\\MainRepositoryInterface

[](#tgalfareposerviceservicescontractsmainrepositoryinterface)

```
    public function getModel();

    public function get(
        array $columns = ['*'],
        array $scopes = [],
        int $perPage = null
    );

    public function paginate(
        int $perPage,
        array $columns = ['*'],
        array $scopes = []
    );

    public function getById(int $id, array $columns = ['*']);

    public function store(array $data);

    public function update(Model $model, array $data);

    public function updateOrCreate(array $attributes, array $data);

    public function delete(Model $model);
```

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.

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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

Recently: every ~140 days

Total

12

Last Release

843d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/31fe1d8a71e7dd17a24e52430616f823a6937c57e279555993cc9eaf9a976c82?d=identicon)[tgalfa](/maintainers/tgalfa)

---

Top Contributors

[![gergo-tar](https://avatars.githubusercontent.com/u/13517318?v=4)](https://github.com/gergo-tar "gergo-tar (38 commits)")

---

Tags

phpclilaravelgeneratorservicerepository

### Embed Badge

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

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

###  Alternatives

[nunomaduro/laravel-console-menu

Laravel Console Menu is an output method for your Laravel/Laravel Zero commands.

815412.0k48](/packages/nunomaduro-laravel-console-menu)[timwassenburg/laravel-service-generator

Generate Laravel services

104233.1k2](/packages/timwassenburg-laravel-service-generator)[timwassenburg/laravel-artisan-extender

A collection of generators for Laravel

111.4k](/packages/timwassenburg-laravel-artisan-extender)[timwassenburg/laravel-repository-generator

Generate Laravel repositories

2116.9k1](/packages/timwassenburg-laravel-repository-generator)

PHPackages © 2026

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