rohitshakyaa/repository-generator

Laravel package to generate repositories with automatic interface and service provider binding.

Maintainers

Package info

github.com/rohitshakyaa/repository-generator

pkg:composer/rohitshakyaa/repository-generator

Statistics

Installs: 95

Dependents: 0

Suggesters: 0

Stars: 3

Open Issues: 0

2.0.0 2026-02-15 05:06 UTC

This package is auto-updated.

Last update: 2026-02-15 05:07:23 UTC


README

This Laravel package adds Artisan commands that:

  • Creates a Repository class and its Interface
  • Supports nested paths like Config.RoleRepository
  • Automatically binds Interface to Implementation in RepositoryServiceProvider
  • (Optional) Creates a Service class (with optional interface) and binds it in ServiceServiceProvider

Installation

composer require rohitshakyaa/repository-generator

If Laravel doesn't auto-discover it, register manually in config/app.php:

'providers' => [
    RohitShakyaa\RepositoryGenerator\RepositoryGeneratorServiceProvider::class,
]

if Laravel >= 11.*, in bootstrap/providers.php

return [
    RohitShakyaa\RepositoryGenerator\RepositoryGeneratorServiceProvider::class,
]

Usage

php artisan make:repository UserRepository
php artisan make:repository Config.RoleRepository

By default this will generate:

app/Repositories/Config/RoleRepository.php
app/Repositories/Config/Interfaces/RoleRepositoryInterface.php

And it will auto-bind them in:

app/Providers/RepositoryServiceProvider.php

Optional: also generate a Service

php artisan make:repository Config.RoleRepository --service

Generate a service + interface + binding:

php artisan make:repository Config.RoleRepository --service --service-interface

make:service

Create only a service class:

php artisan make:service Billing.InvoiceService

Create service + interface + auto-binding:

php artisan make:service Billing.InvoiceService --interface

And to remove repository

php artisan remove:repository UserRepository
php artisan remove:repository Config.RoleRepository

This will remove the files and the binding from RepositoryServiceProvider

Publishing Stubs

To customize the stub files, publish them to your app:

php artisan vendor:publish --tag=repository-generator-stubs

Publishing Config

php artisan vendor:publish --tag=repository-generator-config

Config options

You can change the base folders (relative to app/) and namespaces:

  • repositories.path (default: Repositories)
  • services.path (default: Services)

If you want the old v1.x behavior, set:

// config/repository-generator.php
'repositories' => [
    'path' => 'Http/Repositories',
],