定制 rohitshakyaa/repository-generator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rohitshakyaa/repository-generator

最新稳定版本:2.0.0

Composer 安装命令:

composer require rohitshakyaa/repository-generator

包简介

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

README 文档

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',
],

统计信息

  • 总下载量: 138
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固