承接 vivek-mistry/repository-interface 相关项目开发

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

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

vivek-mistry/repository-interface

最新稳定版本:1.0.1

Composer 安装命令:

composer require vivek-mistry/repository-interface

包简介

Laravel package for dependency injection to separate business logic.

README 文档

README

Repository Interface

Laravel Repository Interface

A Laravel package that leverages dependency injection to cleanly separate business logic from other application layers, promoting better code organization, testability, and adherence to SOLID principles

🛠️ Installation

Install the package via Composer:

composer require vivek-mistry/repository-interface

Get Plain Repository Interface

php artisan app:make-repo {ModelName} --plain

Particular Model Generate the Repository-Interface

php artisan app:make-repo {ModelName}

With basic functions you will get here like,

  • public function createOrUpdate(array $data, $id = null);
  • public function getAll($draw = null, $start = null, $rawperpage = null);
  • public function getRecordById($id, array $with = []);
  • public function getRecordByField(string $field_name, string $field_value);

So using above two files created at app/Repositories/Interface & app/Repositories/Repository

  • ModelNameInterface.php
  • ModelNameInterfaceRepository.php

Create Service Prvider

php artisan make:provider RepositoryServiceProvider

Register Your Service Provider & register your repository

=> Register your service provider

=> In your RepositoryServiceProvider add below :

    public function boot(): void
    {
        $this->app->bind(
            INTERFACE_NAME::class,
            REPOSITORY_NAME::class
        );
    }

HOW TO USE IN YOUR CONTROLLER?

For example :

class UserController extends Controller
{
    protected $userRepository;

    /**
     * Load Repository
     */
    public function __construct(
        UserRepositoryInterface $userRepository
    ) {
        $this->userRepository = $userRepository;
    }

    public function index($request)
    {
        $data = [
            'name' => $request->name,
            'email' => $request->email
        ];
        $this->userRepository->createOrUpdate($data);
    }
}

Testing

composer test

Change Logs

Date : 27 Sept, 2025

  • Update the Minor bugs of functions
  • Added Plain Repository/Interface

Credits

License

MIT License. See LICENSE for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-21