alex-kudrya/laravel-repositories 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

alex-kudrya/laravel-repositories

最新稳定版本:v1.0.3

Composer 安装命令:

composer require alex-kudrya/laravel-repositories

包简介

Structured repository layer for Laravel with contracts, Eloquent adapters, cache decorators, autogenerated tests and CQRS-friendly bindings.

README 文档

README

Total Downloads Version License PHP Version Require

Laravel Repositories

Structured repository layer for Laravel with contracts, Eloquent implementations, cache decorators and CQRS-friendly bindings.

This package provides a production-ready way to generate repositories with:

  • strict contracts
  • Eloquent adapters
  • optional cache decorators (with versioned cache keys)
  • automatic service container bindings
  • ready-to-run unit tests (PHPUnit or Pest)

Generated Repository Structure

root/
├── app/
│   └── Repositories/
│       ├── Contracts/
│       │   └── ProductRepositoryContract.php
│       └── Implementations/
│           ├── Eloquent/
│           │   └── ProductRepository.php
│           └── Cached/
│               └── ProductCacheRepository.php
└── tests/
    └── Unit/
        └── Repositories/
            ├── ProductRepositoryTest.php
            └── ProductCacheRepositoryTest.php

Installation

composer require alex-kudrya/laravel-repositories
// bootstrap/providers.php

return [
    ...
    \AlexKudrya\LaravelRepositories\Providers\RepositoriesServiceProvider::class,
 ]

For Laravel ≤10 the provider can also be registered in config/app.php.

Usage

The package ships with a single artisan command:

php artisan make:repository Product --model=Product

Or run it as an interactive wizard (recommended):

php artisan make:repository

What will be generated

By default it creates:

  • app/Repositories/Contracts/RepositoryContract.php
  • app/Repositories/Implementations/Eloquent/Repository.php
  • app/Repositories/Implementations/Cached/CacheRepository.php (optional)
  • app/Providers/RepositoryServiceProvider.php (created if missing)
  • service container bindings inside RepositoryServiceProvider

Cache decorator

If cache is enabled, the decorator uses versioned cache keys to invalidate all cached lists on write operations (create/update/delete) without tracking each individual key.

Publishing Stubs

You can publish stubs to customize generated code

php artisan vendor:publish --tag=laravel-repositories-stubs

Published to:

  • stubs/laravel-repositories

Testing (PHPUnit / Pest)

The generator can create repository unit tests compatible with PHPUnit or Pest. • If Pest is installed in your app, Pest-style tests will be generated. • Otherwise, PHPUnit tests will be generated.

The tests are designed to be green by default (no skipped, no incomplete, no model-field assumptions).

License

MIT

Alexander Kudria alexkudrya91@gmail.com

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固