Looking to hire Laravel developers? Try LaraJobs

laravel-service-repo-generator maintained by fatihrizqon

Description
Artisan command to generate Service & Repository in Laravel
Last update
2026/01/02 05:34 (dev-main)
License
Links
Downloads
23

Comments
comments powered by Disqus

Laravel Service Repository Generator

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