fatihrizqon/laravel-service-repo-generator

Artisan command to generate Service & Repository in Laravel

Maintainers

Package info

github.com/fatihrizqon/laravel-service-repo-generator

pkg:composer/fatihrizqon/laravel-service-repo-generator

Statistics

Installs: 20

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v1.0.0 2026-01-02 04:34 UTC

This package is auto-updated.

Last update: 2026-03-30 06:39:02 UTC


README

An Artisan command to generate Service & Repository pattern in Laravel projects, complete with interfaces and customizable stubs.

✨ Features

  • Generate Service & Service Interface
  • Generate Repository & Repository Interface
  • Configurable namespaces
  • Customizable stubs via vendor:publish
  • Laravel auto-discovery support
  • Compatible with Laravel 10, 11, and 12

📦 Installation

Install the package via Composer:

composer require fatihrizqon/laravel-service-repo-generator

The service provider will be automatically registered via Laravel auto-discovery.

⚙️ Publish Configuration

(Optional but recommended)

php artisan vendor:publish --tag=service-repo-generator-config

The configuration file will be published to:

config/service-repo-generator.php

🧱 Publish Stubs (Customize Templates)

To customize the service and repository templates:

php artisan vendor:publish --tag=service-repo-generator-stubs

The stubs will be published to:

stubs/service-repo-generator/

🚀 Usage

Generate a Service

php artisan create:service User

This command will generate:

app/Services/UserService.php
app/Services/Interfaces/IUserService.php

Generate a Repository

php artisan create:repository User

This command will generate:

app/Repositories/UserRepository.php
app/Repositories/Interfaces/IUserRepository.php

🛠 Configuration Example

return [
    'service_namespace' => 'Services',
    'service_interface_namespace' => 'Services\\Interfaces',

    'repository_namespace' => 'Repositories',
    'repository_interface_namespace' => 'Repositories\\Interfaces',
];

📄 License

MIT License © 2025
Created by Fatih Rizqon