rafflesargentina/l8-repository
Composer 安装命令:
composer require rafflesargentina/l8-repository
包简介
Reusable Laravel repository interface.
README 文档
README
Caffeinated Repository
Getting Started
Introduction
The Caffeinated Repository package allows the means to implement a standard boilerplate repository interface. This covers the standard Eloquent methods in a non-static, non-facade driven way right out of the box. Fear not though Batman! The Caffeinated Repository package does not limit you in any way when it comes to customizing (e.g overriding) the provided interface or adding your own methods.
Installing Caffeinated Repository
It is recommended that you install the package using Composer.
composer require caffeinated/repository
This package is compliant with PSR-1, PSR-2, and PSR-4. If you find any compliance oversights, please send a patch via pull request.
Using Repositories
Create a Model
Create your model like you normally would. We'll be wrapping our repository around our model to access and query the database for the information we need.
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model class Book extends Model { // }
Create a Repository
Create a new Repository class - usually these classes are simply stored within a Repositories directory. There are a few requirements for each repository instance:
- Repository classes must extend the Caffeinated EloquentRepository class.
- Repository classes must specify a public property pointing to the model.
- Repository classes must specify an array of cache tags. These tags are used by the package to handle automatic cache busting when relevent values change within the database.
<?php namespace App\Repositories; use App\Models\Book; use Caffeinated\Repository\Repositories\EloquentRepository; class BookRepository extends EloquentRepository { /** * @var Model */ public $model = Book::class; /** * @var array */ public $tag = ['book']; }
Injecting a Repository
Once you've built and configured your repository instance, you may inject the class within your classes where needed:
<?php namespace App\Http\Controllers; use App\Repositories\BookRepository; class BookController extends Controller { /** * @var BookRepository */ protected $book; /** * Create a new BookController instance. * * @param BookRepository $book */ public function __construct(BookRepository $book) { $this->book = $book; } /** * Display a listing of all books. * * @return Response */ public function index() { $books = $this->book->findAll(); return view('books.index', compact('books')); } }
rafflesargentina/l8-repository 适用场景与选型建议
rafflesargentina/l8-repository 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 01 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「repository」 「laravel」 「eloquent」 「caffeinated」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rafflesargentina/l8-repository 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rafflesargentina/l8-repository 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rafflesargentina/l8-repository 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
A Laravel Eloquent model trait for translatable resource
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Help to manage meta data on Laravel Eloquent model
A package to cast json fields, each sub-keys is castable
Laravel 5 - Repositories to the database layer
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-01-20