New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

techrays-labs/laravel-service-repository-generator

A powerful and flexible Laravel package that simplifies the implementation of the Service-Repository design pattern. Generate Service and Repository classes with ease, customize their namespace and path, and streamline your application's architecture.
1,630

Larablocks Analysis

techrays-labs/laravel-service-repository-generator works with Laravel 8 to 11 (latest release v1.0.0, Feb 6, 2025), all past end of life (the last on Mar 12, 2026): no more fixes, even for security.

Recommendation checks

Use with care

Use with care: meets 0 of 4 checks.

  • Supports only Laravel 8 to 11, past end of life since Mar 12, 2026
  • No release in the last 12 months (last: Feb 6, 2025)
  • 0 downloads a month (needs 10,000)
  • 0 GitHub stars (needs 100)

State

Quiet
  • Last stable release: Feb 6, 2025.
  • No releases in the last 12 months.
  • First released: Feb 6, 2025.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 28, 2026.

Install
composer require techrays-labs/laravel-service-repository-generator
Latest Version:v1.0.0
PHP:>=8.0
Laravel:8 – 11
License:MIT
Last Updated:Feb 6, 2025
Links: GitHub  ·  Packagist
Maintainer: techrays-labs

Laravel Service & Repository Generator

A powerful and flexible Laravel package that simplifies the implementation of the Service-Repository design pattern. Generate Service and Repository classes with ease, customize their namespace and path, and streamline your application's architecture. Perfect for developers who follow clean code principles and want a structured approach to business logic and data handling in Laravel applications.

Laravel Version
License

Features

  • Generate Service & Repository classes automatically
  • Supports custom namespaces & paths
  • Option to generate a Repository Interface
  • Automatic binding in AppServiceProvider
  • Uses stub files for customization
  • Publishable configuration file
  • Compatible with Laravel 8, 9, and 10

Installation

Install via Composer

composer require techrays-labs/laravel-service-repository-generator

Publish the configuration file


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

Publish the stub files (optional)


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

Configuration

The package allows you to define default namespaces and paths in config/service-repository.php


<?php
return [
    'service_namespace' => 'App\Services',
    'repository_namespace' => 'App\Repositories',
];

You can modify these settings to match your project structure.

Usage

Basic Usage

Generate a Service & Repository for User

php artisan make:service-repository User

This will create

app/
├── Services/
│   ├── UserService.php
├── Repositories/
│   ├── UserRepository.php

Custom Namespace for Service

php artisan make:service-repository User --serviceNamespace="Domain\Services"

This will place the service in Domain\Services

Domain/
├── Services/
│   ├── UserService.php

Custom Path for Repository

php artisan make:service-repository User --repositoryNamespace="Domain\Repositories"

This will place the repository in Domain\Repositories

Domain/
├── Repositories/
│   ├── UserRepository.php

Generate Repository Interface

php artisan make:service-repository User --interface

This will generate an interface alongside the repository

app/
├── Repositories/
│   ├── UserRepository.php
│   ├── UserRepositoryInterface.php

Combine Multiple Options

php artisan make:service-repository User --serviceNamespace="Domain\Services" --repositoryNamespace="Domain\Repositories" --interface

This will generate

Domain/
├── Services/
│   ├── UserService.php
├── Repositories/
│   ├── UserRepository.php
│   ├── UserRepositoryInterface.php

Stubs Customization

After publishing the stub files, you can find them in stubs/service-repository-generator/

Modify these stubs to customize the generated files

  • service.stub – Template for service class
  • repository.stub – Template for repository class
  • repository-interface.stub – Template for repository interface

Example of a custom service stub (service.stub)

<?php

namespace {{ namespace }};

class {{ className }}
{
    protected $repository;

    public function __construct({{ className }}Repository $repository)
    {
        $this->repository = $repository;
    }
}

Automatic Binding in Service Provider

If you generate an interface, the package automatically binds it in AppServiceProvider.php

$this->app->bind(UserRepositoryInterface::class, UserRepository::class);

Example Usage in Code

Inject Service into a Controller

<?php

use App\Services\UserService;

class UserController extends Controller
{
    protected $userService;

    public function __construct(UserService $userService)
    {
        $this->userService = $userService;
    }
}

Use Repository in a Service

<?php

namespace App\Services;

use App\Repositories\UserRepository;

class UserService
{
    protected $userRepository;

    public function __construct(UserRepository $userRepository)
    {
        $this->userRepository = $userRepository;
    }

    public function getAllUsers()
    {
        return $this->userRepository->all();
    }
}

Contributing

Want to improve this package? Contributions are welcome!

  • Fork the repository
  • Create a new branch feature/awesome-feature
  • Commit your changes
  • Push the branch
  • Submit a Pull Request

License

This package is open-sourced software licensed under the MIT License.

Happy Coding! 🎉

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

670,032,257 9,703
laravel/framework

The Laravel Framework.

640,572,096 35,338
laravel/tinker

Powerful REPL for the Laravel framework.

546,909,908 7,440
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

465,816,364 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

431,187,642 4,660

Version History

Version Released PHP Laravel License
v1.0.0 >=8.0 ^8.0|^9.0|^10.0|^11.0 MIT