承接 kamarkoding/kamarkoding-repository 相关项目开发

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

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

kamarkoding/kamarkoding-repository

Composer 安装命令:

composer require kamarkoding/kamarkoding-repository

包简介

Repository generator for Laravel

README 文档

README

Generator sederhana untuk membuat Repository Pattern di Laravel secara otomatis.
Package ini membantu menjaga arsitektur aplikasi tetap rapi, terstruktur, dan mengikuti prinsip SOLID.

Fitur Utama

  • Membuat Repository Interface dan Repository Class hanya dengan satu perintah.
  • Struktur folder otomatis dibuat:
    • app/Repository/Contracts
    • app/Repository/Eloquent
  • Binding otomatis interface → implementasi (tanpa perlu menambahkan di AppServiceProvider)
  • Menggunakan Laravel Package Auto-Discovery (tanpa daftar provider manual).
  • Kode bersih, ringan, dan cocok untuk aplikasi kecil maupun besar.

Instalasi

1. Tambahkan repository (jika lokal)

Jika package disimpan secara lokal:

"repositories": [
    {
        "type": "path",
        "url": "../kamarkoding-repository"
    }
]
  1. Install melalui Composer
composer require kamarkoding/kamarkoding-repository

Laravel otomatis mendaftarkan Service Provider melalui auto-discovery.

Jika auto-discovery dimatikan, daftar manual di config/app.php:

'providers' => [
    Kamarkoding\KamarkodingRepository\Providers\RepositoryServiceProvider::class,
];

Membuat Repository Baru

Gunakan perintah berikut:

php artisan make:repository User

Output :

Created: Class UserRepositoryInterface.php
Created: Class UserRepository.php
Repository created successfully.
app/
└── Repository/
    ├── Contracts/
    │   └── UserRepositoryInterface.php
    └── Eloquent/
        └── UserRepository.php

Struktur Folder

Struktur lengkap setelah membuat repository:

app/
└── Repository/
    ├── Contracts/
    │   └── <Name>RepositoryInterface.php
    └── Eloquent/
        └── <Name>Repository.php

File: Interface

<?php

namespace App\Repository\Contracts;

interface UserRepositoryInterface
{
    //
}

File: Implementasi

<?php

namespace App\Repository\Eloquent;

use App\Repository\Contracts\UserRepositoryInterface;

class UserRepository implements UserRepositoryInterface
{
    //
}

Binding Otomatis

Package ini otomatis menghubungkan:

UserRepositoryInterface::class → UserRepository::class

Tidak perlu lagi menambahkan:

$this->app->bind(UserRepositoryInterface::class, UserRepository::class);

Penggunaan dalam Controller Laravel

<?php

namespace App\Http\Controllers;

use App\Repository\Contracts\UserRepositoryInterface;

class UserController extends Controller
{
    protected $Users;

    public function __construct(UserRepositoryInterface $Users)
    {
        $this->Users = $Users;
    }

    public function index()
    {
        $data = $this->Users->getAll(); // contoh method
        return view('Users.index', compact('data'));
    }
}

Penggunaan di Livewire Component

<?php

use Livewire\Component;
use App\Repository\Contracts\UserRepositoryInterface;

protected UserRepositoryInterface $userRepository;

class UserIndex extends Component
{
    public UserRepositoryInterface $Users;

    /**
    * Inject repository langsung dari container.
    */
    public function mount(UserRepositoryInterface $userRepository)
    {
        $this->userRepository = $userRepository;
    }

    public function delete($id)
    {
        $this->Users->delete($id);
    }

    public function render()
    {
        return view('livewire.user.index');
    }
}

Atau menggunakan resolver otomatis:

public function getRepository()
{
    return app(UserRepositoryInterface::class);
}

Penjelasan Arsitektur

Repository Pattern membantu:

  1. Memisahkan business logic dari data layer
  2. Mengurangi duplikasi query
  3. Meningkatkan testability (mocking jadi mudah)
  4. Memperjelas struktur project Memudahkan perubahan dari Eloquent ke Query Builder atau API tanpa mengubah Controller

kamarkoding/kamarkoding-repository 适用场景与选型建议

kamarkoding/kamarkoding-repository 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 115 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 kamarkoding/kamarkoding-repository 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kamarkoding/kamarkoding-repository 我们能提供哪些服务?
定制开发 / 二次开发

基于 kamarkoding/kamarkoding-repository 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-17