shreifelagamy/laravel-service-modules
Composer 安装命令:
composer require shreifelagamy/laravel-service-modules
包简介
Generate modular service architecture for Laravel applications
README 文档
README
A Laravel package to easily generate service modules for your Laravel applications.
Understanding the Architecture
To gain a deeper understanding of the architecture and how to effectively use service modules in Laravel, you can read this Medium article:
Simplify External API Integrations in Laravel Using Service Modules
This article provides insights into the benefits and implementation details of using service modules for external API integrations in Laravel applications.
Installation
You can install the package via composer:
composer require shreifelagamy/laravel-service-modules
Usage
php artisan service:generate UserService
This will create a new service class in the app/Services directory.
During the generation process, you will be prompted to:
- Generate an exception for the service
- Add methods to the repository
- Include Data Transfer Objects (DTOs) for the service
These prompts allow you to customize the service module according to your needs.
The generated service structure will look like this:
app/Services/UserService/
├── Providers/
│ └── UserServiceProvider.php
├── Repositories/
│ ├── UserServiceInterface.php
│ └── UserServiceRepository.php
├── Facades/
│ └── UserService.php
├── Exceptions/ (optional)
│ └── UserServiceException.php
└── DTOs/ (optional)
└── UserData.php
Configuration
The package comes with a default configuration file that you can publish to customize the behavior:
php artisan vendor:publish --tag=laravel-service-modules-config
This will create a config/laravel-service-modules.php file where you can modify the default settings.
Customization
You can control the directory name for generated services through the config file. This allows you to customize where your service modules are created within your Laravel application.
TODO
We're constantly working to improve this package. Here are some features we're planning to add in the future:
- Support auto-creating PHPDoc for facades to include method definitions.
- Add more customization options for DTOs.
Stay tuned for these upcoming enhancements!
License
The Laravel Services Generator is open-sourced software licensed under the MIT license.
shreifelagamy/laravel-service-modules 适用场景与选型建议
shreifelagamy/laravel-service-modules 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.85k 次下载、GitHub Stars 达 48, 最近一次更新时间为 2024 年 10 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 shreifelagamy/laravel-service-modules 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shreifelagamy/laravel-service-modules 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 48
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-09
