定制 interreposerv/inreser 二次开发

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

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

interreposerv/inreser

最新稳定版本:v2.1.0

Composer 安装命令:

composer require interreposerv/inreser

包简介

A package for creating interface, repository, and service and other classes in Laravel

README 文档

README

( Interface/Repository/Service )A Laravel package to streamline the process of creating Interfaces, Repositories, Services, and DTOs (Data Transfer Objects) in a Laravel project. This package enables you to follow clean coding practices by using the Repository Pattern and Service Layer Pattern, promoting a modular and testable application structure.

Installation

To install the package, run the following command:

composer require interreposerv/inreser


Usage

1. Creating an Interface

This command generates a new interface file under the app/Interfaces directory:

php artisan make:interface YourInterfaceName

Replace YourInterfaceName with the desired name of the interface. Interfaces define the structure of methods that implementing classes will use, providing consistency across your application.

2. Creating a Repository

This command creates a repository class in the app/Repositories directory, optionally implementing a specific interface:

php artisan make:repository YourRepositoryName

To make the repository implement an interface, use the --interface option:

php artisan make:repository YourRepositoryName --interface=YourInterfaceName

Replace YourRepositoryName with the repository name and YourInterfaceName with the interface name. Using repositories separates data logic from controllers, making it easier to swap data sources without modifying the interface.

3. Creating a Service

To create a service class, run:

php artisan make:service YourServiceName

This generates a new service class in the app/Services directory. Services encapsulate business logic and promote code reusability across different parts of your application.

4. Creating a DTO (Data Transfer Object)

Data Transfer Objects (DTOs) help manage data structures by ensuring data integrity and keeping code organized. To create a DTO, use:

php artisan make:dto YourDtoName

This command generates a DTO class in app/DTOs with predefined methods for transforming data to and from arrays.

5. Creating a Trait

Traits allow you to share methods across multiple classes without using inheritance. To generate a new trait in your Laravel project, run:

php artisan make:trait YourTraitName

This command creates a new trait in the app/Traits directory.

Additional Information

This package automatically registers these artisan commands, allowing for easy generation of Interfaces, Repositories, Services, and DTOs with a consistent structure across your Laravel application.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-10-17