A client for remote calling microservice communication
alicfeng/service-client is a Laravel package for a client for remote calling microservice communication.
It currently has 4 GitHub stars and 19 downloads on Packagist (latest version 1.0.0).
Install it with composer require alicfeng/service-client.
Discover more Laravel packages by alicfeng
or browse all Laravel packages to compare alternatives.
Last updated
一款远程调用微服务通讯的客户端
支持多种通讯协议的远程调用客户端,安装一个客户端可配置灵活调用多个服务
standardcomposer require alicfeng/service-client -vvv
Laravelphp artisan vendor:publish --provider="Samego\Client\ServiceProvider\ServiceClientProvider"
[x] Http
[ ] ICE
[ ] Grpc
<?php
return [
'arrangement' => [
'success_code' => 1000,
],
// 协议驱动 HTTP
'http' => [
// 路由列表
'routes' => [
// 服务路由 服务名称.路由别名
'user.profile' => [
'uri' => '/api/user',
'method' => 'GET',
'headers' => [
],
],
],
// 服务分组 配置每组服务通用配置
'groups' => [
'user' => [
'timeout' => 60,
'base_uri' => env('SERVICE_CLIENT_USER_SERVER_BASE_URI'),
'verify' => env('SERVICE_CLIENT_USER_SERVER_VERIFY', false),
'headers' => [
],
],
],
],
];
use Samego\Client\Facades\ServiceHttpClient;
// 简单请求
ServiceHttpClient::service('user.profile')->request();
// 复杂请求
ServiceHttpClient::service('user.profile')->package(['name'=>'samego'])->header(['Auth'=>'token'])->uri('api/user/profile')->request();
Http 提供服务的建议使用 laravel-response 作为配套响应组件