定制 blaisebueno/laravel-repository 二次开发

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

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

blaisebueno/laravel-repository

Composer 安装命令:

composer require blaisebueno/laravel-repository

包简介

A Laravel package implementing a clean, scalable repository design pattern architecture to abstract data persistence and promote testable, maintainable code.

README 文档

README

A Laravel package implementing a clean, scalable repository design pattern architecture to abstract data persistence and promote testable, maintainable code.

Installation

Step 1: Install via Composer

Run the following command in your Laravel project:

composer require blaisebueno/laravel-repository

Step 2: Register the Service Provider for Publishing

If you are using Laravel 5.5+ with package auto-discovery, you can skip this step.
Otherwise, you need to manually register the service provider.

For Laravel 10 and Below

Add the service provider in config/app.php:

For Laravel 11 and Above

Add the service provider in bootstrap/providers.php:

\BlaiseBueno\LaravelRepository\LaravelRepositoryServiceProvider::class,

Step 3: Publish Files

Run the following command to publish the repository stubs:

php artisan vendor:publish --provider="BlaiseBueno\LaravelRepository\LaravelRepositoryServiceProvider"

This will publish the following:

  • app/Providers/RepositoryServiceProvider.php
  • app/Console/Commands/MakeRepository.php
  • app/Repositories/BaseRepository.php
  • app/Repositories/Interfaces/EloquentInterface.php

Adding --force flag will overwrite existing files.

Step 4: Register the Repository Service Provider

For Laravel 10 and Below

Add the service provider in config/app.php:

For Laravel 11 and Above

Add the service provider in bootstrap/providers.php:

App\Providers\RepositoryServiceProvider::class,

Step 5: Register the make:repository Command

⚠️ In Laravel 11 and above, Kernel.php has been removed. Custom commands in app/Console/Commands are now auto-discovered.

⚠️ If your App\Console\Kernel contains the default line below, no manual registration is required:

$this->load(__DIR__.'/Commands');

If you're using a custom path or want to register explicitly, add the following in app/Console/Kernel.php:

protected $commands = [
    \App\Console\Commands\MakeRepository::class,
];

Step 6: Usage

You can now generate a new repository using:

php artisan make:repository User

This will create:

  • app/Repositories/UserRepository.php
  • app/Repositories/Interfaces/UserInterface.php

Adding --force flag will overwrite existing files.

If you want to generate a corresponding service file, add the --s flag:

This will additionally create:

  • app/Services/UserService.php

Modify these files according to your needs.

License

This package is open-source and available under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

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