kroderdev/laravel-microservice-core
Composer 安装命令:
composer require kroderdev/laravel-microservice-core
包简介
A toolkit to use Laravel effectively as a microservice in a distributed architecture.
README 文档
README
A Laravel package that simplifies building microservices in distributed architectures. It provides authentication, request handling, and service-to-service communication tools to make Laravel scalable and production-ready in microservice environments.
Key Features
This package packages common microservice concerns so you can focus on your service logic:
- JWT authentication middleware and a session guard for frontend interactions
- Correlation ID propagation for tracing requests across services
- Role and permission gates with convenient helpers
- HTTP client macros and a configurable API Gateway client
- Base model and query builder class for working with remote resources through the gateway
- Optional health check endpoint out of the box
Quick start
Install the package via Composer:
composer require kroderdev/laravel-microservice-core
Publish the configuration to customize defaults:
php artisan vendor:publish --provider="Kroderdev\LaravelMicroserviceCore\Providers\MicroserviceServiceProvider"
Basic usage
Configure your API gateway URL and JWT settings in config/microservice.php.
Then extend the base model to interact with remote resources:
Scaffold your remote model via the new Artisan command:
php artisan make:model RemoteUser --remote
This will generate a RemoteUser model that extends the core Model class with remote-resource support.
use Kroderdev\LaravelMicroserviceCore\Models\Model; class RemoteUser extends Model { protected static string $endpoint = '/users'; protected $fillable = ['id', 'name']; } $users = RemoteUser::all();
Add the provided middleware to your routes to validate JWTs and propagate correlation IDs:
Route::middleware(['jwt.auth'])->group(function () { Route::get('/profile', fn () => 'ok'); });
Documentation
Full documentation lives in the project wiki.
Contributing
Contributions welcome! See CONTRIBUTING.md for guidelines.
License
This project is open-sourced software licensed under the MIT license.
kroderdev/laravel-microservice-core 适用场景与选型建议
kroderdev/laravel-microservice-core 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 150 次下载、GitHub Stars 达 5, 最近一次更新时间为 2025 年 06 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 kroderdev/laravel-microservice-core 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kroderdev/laravel-microservice-core 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 150
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-18