定制 ahmedmahmoud/repository-pattern 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ahmedmahmoud/repository-pattern

最新稳定版本:5.0.0

Composer 安装命令:

composer require ahmedmahmoud/repository-pattern

包简介

A Laravel package to implement the Repository Pattern

README 文档

README

This 'Package' support only api A powerful package to automatically generate the complete repository pattern structure for your Laravel applications.

Features

  • 🚀 Auto-generates all repository pattern components with one command
  • 📦 Includes: Model, Repository, Service, Controller, Form Requests, Migration
  • 🔄 Supports both API
  • ⚡ Easily extendable base classes
  • 🔧 Customizable stubs

Installation

  1. Require the package via Composer:
composer require ahmedmahmoud/repository-pattern

2.(Optional) Publish stubs for customization:

php artisan vendor:publish --tag=repository-stubs --force
  1. Run the setup command to install base files:
php artisan repository:setup
  1. Generate complete structure for a new model:
php artisan make:repo {name : The name of the repository} --all (Includes: Model, Repository, Service, Controller, Form Requests, Migration}

🧩 Dependency Injection Binding

The package automatically registers repository bindings in the service container:

$this->app->when(ProductService::class)
    ->needs(RepositoryInterface::class)
    ->give(ProductRepository::class);

if you not install api this return in your terminal

out when installed api then try this command again

php artisan make:repo student --all
Created migration file for students table.
Cannot write to C:\xampp_new\htdocs\first_package\routes/api.php. Please manually add the following to routes/api.php:
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\StudentController;

Route::resource('students', StudentController::class);
Repository pattern files for Student created successfully!

How it works:

  1. when(): Specifies the service class that needs dependency
  2. needs(): Defines the interface/abstract type needed
  3. give(): Provides the concrete implementation

You can find these bindings in: app/Providers/RepositoriesServiceProvider.php

And File bootstrap/providers/RepositoriesServiceProvider.php

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-23