idtitanium/laravel-api-interface-gen

在构建API时,一个有用的artisan命令,用于生成接口及其仓库。

v1.0.1 2020-04-05 15:59 UTC

This package is auto-updated.

Last update: 2024-09-29 05:36:12 UTC


README

Build Status GitHub Packagist Version

laravel-api-interface-gen

提供有用的artisan命令,帮助生成仓库和接口。

用法

  1. 安装:要安装,请运行composer require idtitanium/laravel-api-interface-gen。支持Laravel版本6.1或更高。较低版本可能无法正常工作。

  2. 创建接口:当你运行php artisan make:interface Book时。这将生成两个文件夹(如果它们不存在)。一个名为“Repositories”,其中包含“Interfaces”。然后,在“Interfaces”文件夹中创建BookRepositoryInterface

  3. 创建仓库:当你运行php artisan make:repository Book时。这将生成一个名为BookRepository的仓库类,假设你已经有了一个名为BookRepositoryInterface的接口。

  4. 创建仓库和接口。这是本包最好的部分。当你运行php artisan make:repositoryinterface Book时。它将在各自的文件夹和正确的命名空间中创建仓库和接口。

  5. 所有命令都会创建一个RepositoryServiceProvider文件,如果它当前不存在。

注意:这些命令目前不会在app配置中注册服务提供者。它还会创建一个没有将仓库绑定到接口的服务提供者。