felipedamacenoteodoro/makeservicerepository

生成服务和服务仓库文件及接口

v1.0.3 2022-01-09 19:25 UTC

README

快速生成使用 Laravel 包项目的服务和服务仓库文件命令 make。

安装

通过 Composer

composer require felipedamacenoteodoro/makeservicerepository --dev

自定义目录

发布配置文件并自定义服务和服务仓库文件夹

php artisan vendor:publish --tag=makeservicerepository-config

用法

打开控制台并输入以下命令之一

  • 生成一个新服务和服务仓库接口的所有文件
php artisan make:crudsrv {Entity_name}
  • 仅生成仓库接口类
php artisan make:repository {Entity_name} --interface 
  • 仅生成服务接口类
php artisan make:service {Entity_name} --interface
  • 生成一个服务,系统会询问你是否要创建接口
php artisan make:service {Entity_name}
  • 生成一个仓库,系统会询问你是否要创建接口
php artisan make:repository {Entity_name}

注意

您需要在您的应用服务器提供商上映射接口绑定。

  • 示例

在你的服务提供商的 boot 方法中添加 app/Providers/AppServiceProvider.php

  • 在 boot 方法中添加
$this->app->bind(YourEntityCreatedServiceInterface::class, YourEntityCreatedService::class);
$this->app->bind(YourEntityCreatedRepositoryInterface::class, YourEntityCreatedRepository::class);

变更日志

请参阅 CHANGELOG 了解最近更改的更多信息。