aidias / gelb-repository
Laravel应用程序的仓库结构
dev-master
2020-10-30 12:14 UTC
Requires
- php: ^7.2
This package is auto-updated.
Last update: 2024-09-29 05:02:41 UTC
README
Laravel应用程序的仓库结构。
入门指南
以下说明将帮助您获取并运行项目副本。
先决条件
- Laravel >= 5.8
- PHP >= 7.2
安装
composer require aidias/gelb-repository
- 包安装后,运行
php artisan gelb:repository:init
这将在您的Laravel应用程序中创建以下GelbRepository结构
app\Providers\RepositoryServiceProvider.php
:这是仓库注入的服务提供者。app\Repositories
:它将包含所有相关仓库的文件;app\Repositories\Interfaces\AbstractInterface.php
:此接口将为其他仓库实现提供公共基本规则;app\Repositories\Eloquent\AbstractEloquent.php
:这是对AbstractInterface.php
的Eloquent实现。您可以使用其他框架通过使用此指南;
- 在
config\app.php
的 providers 数组中注册RepositoryServiceProvider
'providers' => [ ... App\Providers\RepositoryServiceProvider::class, ... ],
用法
- 例如,要创建一个
Post
仓库,运行
php artisan gelb:make:repository Post
这将会创建以下文件(如果它们不存在的话)
app\Http\Controllers\PostController.php
app\Http\Requests\PostStoreRequest.php
app\Http\Requests\PostUpdateRequest.php
app\Repositories\Eloquent\PostEloquent.php
app\Repositories\Interfaces\PostInterface.php
app\Post.php
作者
许可
本项目采用MIT许可 - 有关详细信息,请参阅LICENSE.md 文件。