定制 mitul456/laravel-repository-service 二次开发

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

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

mitul456/laravel-repository-service

最新稳定版本:1.0.6

Composer 安装命令:

composer require mitul456/laravel-repository-service

包简介

A Laravel package to generate repository and service layers using artisan commands

README 文档

README

Latest Version on Packagist Total Downloads License PHP Version

A powerful Laravel package to automatically generate Repository and Service layers, helping you build clean, maintainable, and testable applications.

🇧🇩 বাংলা: এটি একটি Laravel প্যাকেজ যা Repository Pattern এবং Service Layer স্বয়ংক্রিয়ভাবে তৈরি করে, আপনার কোডকে আরও ক্লিন এবং মেইন্টেইনেবল করে তোলে।

⚡ Quick Start

Install the package via Composer:

composer require mitul456/laravel-repository-service

php artisan make:repository UserRepository
php artisan make:service UserService

✨ Features

  • 🚀 Auto generate Repository and Service classes
  • 📦 Base repository trait with common CRUD operations
  • 🔧 Generate Repository or Service separately
  • 💉 Dependency Injection ready
  • 📝 Configurable namespaces and paths
  • 🎯 PSR-4 compliant
  • 🎨 Clean architecture friendly

🤔 Why use this package?

  • Keep controllers clean and focused
  • Separate business logic from controllers
  • Improve code maintainability
  • Make testing easier
  • Follow clean architecture principles

📋 Requirements

  • PHP ^8.0 or higher
  • Laravel ^10.0 or ^11.0
  • Composer

🔧 Installation

Install the package via Composer:

composer require mitul456/laravel-repository-service

Auto Discovery

This package supports Laravel auto-discovery. No need to manually register any service provider.

⚙️ Configuration

If you want to customize namespaces or paths, publish the config file:

php artisan vendor:publish --tag=repository-service-config

🚀 Usage

1. Create Repository and Service Together

php artisan make:repository-service User

📌 Example Usage

Repository Example

class UserRepository
{
    public function getAll()
    {
        return User::all();
    }
}

Service Example

class UserService
{
    protected $repository;

    public function __construct(UserRepository $repository)
    {
        $this->repository = $repository;
    }

    public function getUsers()
    {
        return $this->repository->getAll();
    }
}

Controller Example

class UserController extends Controller
{
    protected $service;

    public function __construct(UserService $service)
    {
        $this->service = $service;
    }

    public function index()
    {
        return $this->service->getUsers();
    }
}

📁 Directory Structure

Example structure generated by the package:

app/
 ├── Repositories/
 │    └── UserRepository.php
 ├── Services/
 │    └── UserService.php

🧪 Testing

Run your Laravel tests:

php artisan test

⚠️ Troubleshooting

  • Run composer dump-autoload if classes are not found
  • Ensure correct namespace configuration
  • Check Laravel version compatibility

🤝 Contributing

Contributions are welcome!

  1. Fork the repository
  2. Create a new branch
  3. Make your changes
  4. Submit a pull request

📄 License

This package is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固