承接 shamaseen/laravel-repositories 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

shamaseen/laravel-repositories

最新稳定版本:3.0.3

Composer 安装命令:

composer require shamaseen/laravel-repositories

包简介

repository pattern files generator

README 文档

README

Build Status Scrutinizer Code Quality Code Intelligence Status

A Laravel Repository generator with the best practice and tools already set and ready to be used.

What this package do?

  1. Commands to generate files, including repository files and others.
  2. Enforcing single responsibility principle
  3. Automatic CRUD out-of-the-box, whenever you generate a repository it will be CRUD-ready.
  4. Automatic query searching - (when the frontend send search GET param)
  5. Automatic query sorting - (when the frontend send order GET param)
  6. Automatic query filtration

Introduction

This package aim to provide auto file generation and base classes for the repository design pattern on Laravel.

Repository pattern forces you to have repository files in mediate between controllers and models, acting like a container where data access logic and business logic are stored.

What is wrong with the MVC pattern?

MVC Violate the single responsibility principle in SOLID principles, where controller methods are responsible for the business logic and returning responses to the front-end users in the same time, making it impossible to re-use these methods or to independently testing the business logic in them.

How repository design pattern works in this package?

After a request is being sent to the Laravel application, it follows these steps:

  1. The route catch the request and redirect it to its method in the controller
  2. The controller then validate the request with the correct request file.
  3. If the validations passed, the controller then check the policy authorization if available.
  4. If it passed the controller then call the repository to retrieve the required data.
  5. The repository implement the business logic and call the model to retrieve the required data from the database accordingly.
  6. The repository process that data (if needed) and return the final result to the controller
  7. The controller passes that data to the resource file to format the data as needed.
  8. The controller finally return the response back to the user.

repository_pattern.png

Quick Usage

Run:

php artisan generate:repository Test

This will generate the following files:

  1. Test - (the Model file)
  2. TestController
  3. TestRepository
  4. TestRequest
  5. TestResource
  6. TestPolicy
  7. TestTest

Read the full document on ReadTheDoc.

LICENSE

MIT License

Versioning

We follow Semantic Versioning

Roadmap

  1. add the ability to disable caching from the config.

统计信息

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

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-12-06