Hprose RPC 服务 in Laravel/Lumen

Overview

基于 hprose/hprose-php 开发的Laravel扩展:whereof/laravel-hprose

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

安装

composer require whereof/laravel-hprose

配置文件

[ // 如果设置false 在控制台显示调用方法,否在在路由显示调用方法 'enable' => false, //如果设置了true 这里就是路由前缀 'route_prefix' => 'rpc' ], ], //rpc 客户端 'client' => [ // 服务端监听地址 'tcp_uris' => [ 'tcp://127.0.0.1:1314', ], //是否异步 'async' => false ], ]; ">
 [
        // hprose 调试模式
        'debug' => true,
        //监听地址
        'tcp_uris'       => [
            'tcp://0.0.0.0:1314',
        ],
        //注册rpc 服务 目录地址
        'route_path'     => glob(base_path("rpc") . '/*.php'),
        // 通过路由查看注册的方法
        'http'           => [
            // 如果设置false 在控制台显示调用方法,否在在路由显示调用方法
            'enable'       => false,
            //如果设置了true 这里就是路由前缀
            'route_prefix' => 'rpc'
        ],
    ],
    //rpc 客户端
    'client' => [
        // 服务端监听地址
        'tcp_uris' => [
            'tcp://127.0.0.1:1314',
        ],
        //是否异步
        'async'    => false
    ],
];

日志记录 /config/logging.php

'channels' => [
     ............
     'hprose' => [
      	'driver' => 'daily',
      	'path'   => storage_path('logs/hprose.log'),
      	'days'   => 14,
      ],
]

非强制配置,不配置,就会走默认的日志记录

laravel配置

//在 `config/app.php` 注册 HproseServiceProvider 
'providers' => [
    .....
    \whereof\laravel\hprose\HproseServiceProvider::class
]
php artisan vendor:publish --provider="whereof\laravel\hprose\HproseServiceProvider"

Lumen配置

将配置信息放在/config/hprose.php

/bootstrap/app.php
$app->register(\whereof\laravel\hprose\HproseServiceProvider::class);

/路由注册 rpc/demo.php

服务端 方法注入,类注入以及目录下类注入

使用addPath的时候要注意:在类中构造方法__construct 参数不能是必传参数.

启动rpc服务

php artisan hprose:socket

客户端调用

$uris =['tcp://127.0.0.1:1314'];
$client = new \whereof\laravel\hprose\Clients\SocketClient($uris, false);
$client->hello()
$client->whereof_hprose_demoService->kan()

需要配置配置
'client' => [
  'tcp_uris' => [
  	'tcp://127.0.0.1:1314',
  ],
	'async' => false
],
app('hprose.socket.client')->hello()
You might also like...
Simple app for geoip - Lumen GeoIP Service

Lumen GeoIP Service Requirements PHP = 8 Required packages: https://github.com/maxmind/GeoIP2-php Install Install Composer packages: composer install

Laravel Blog Package. Easiest way to add a blog to your Laravel website. A package which adds wordpress functionality to your website and is compatible with laravel 8.
Laravel Blog Package. Easiest way to add a blog to your Laravel website. A package which adds wordpress functionality to your website and is compatible with laravel 8.

Laravel Blog Have you worked with Wordpress? Developers call this package wordpress-like laravel blog. Give our package a Star to support us ⭐ 😍 Inst

A Simple Linode SDK built for Laravel with @JustSteveKing laravel-transporter package

linode client A Simple Linode client built for Laravel with @JustSteveKing laravel-transporter package Installation You can install the package via co

A Laravel Wrapper for the Binance API. Now easily connect and consume the Binance Public & Private API in your Laravel apps without any hassle.
A Laravel Wrapper for the Binance API. Now easily connect and consume the Binance Public & Private API in your Laravel apps without any hassle.

This package provides a Laravel Wrapper for the Binance API and allows you to easily communicate with it. Important Note This package is in early deve

Laravel Podcast Manager is a complete podcast manager package for Laravel 5.3+ that enables you to manage RSS feeds for your favorite podcasts and listen to the episodes in a seamless UI.
Laravel Podcast Manager is a complete podcast manager package for Laravel 5.3+ that enables you to manage RSS feeds for your favorite podcasts and listen to the episodes in a seamless UI.

laravelpodcast | A Laravel podcast manager package - v0.0.8 Introduction Laravel Podcast Manager is a complete podcast manager package for Laravel 5.3

Laravel-htaccess - a package for dynamically edit .htaccess in laravel

laravel-htaccess a package for dynamically edit .htaccess in laravel use RedirectHtaccess Facade function for add RedirectHtaccess()-add(); return in

Laravel & Google Drive Storage - Demo project with Laravel 6.x and earlier

Laravel & Google Drive Storage Demo project with Laravel 8.X Look at the commit history to see each of the steps I have taken to set this up. Set up t

Empower your business to accept payments globally, earn rewards and invest in crypto with lazerpay laravel sdk in your laravel project.
Empower your business to accept payments globally, earn rewards and invest in crypto with lazerpay laravel sdk in your laravel project.

Lazerpay Laravel Package pipedev/lazerpay is a laravel sdk package that access to laravel api Installation PHP 5.4+ and Composer are required. To get

Laravel package for Mailjet API V3 and Laravel Mailjet Mail Transport

Laravel Mailjet Laravel package for handling Mailjet API v3 using this wrapper: https://github.com/mailjet/mailjet-apiv3-php It also provides a mailje

Releases(1.0.0)
Owner
wangzhiqiang
自由开发者Free developer
wangzhiqiang
YCOM Impersonate. Login as selected YCOM user 🧙‍♂️in frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Friends Of REDAXO 17 Sep 12, 2022
Php-rpc-server - JSON RPC server implementation for PHP.

JSON RPC Server implementation for PHP. The json-rpc is a very simple protocol. You can see this by reading the protocol specification. This library i

null 4 Sep 28, 2022
A light-weight RPC implement of google protobuf RPC framework.

sofa-pbrpc A light-weight RPC implementation of Google's protobuf RPC framework. Wiki: https://github.com/baidu/sofa-pbrpc/wiki Features High performa

Baidu 2.1k Dec 10, 2022
Zilliqa PHP is a typed PHP-7.1+ interface to Zilliqa JSON-RPC API.

Zilliqa PHP is a typed PHP-7.1+ interface to Zilliqa JSON-RPC API. Check out the latest API documentation. Add library in a composer.json file.

Patrick Falize 6 Oct 7, 2021
Simple XML-RPC API

Readme Ripcord: Easy XML-RPC Client and Server for PHP 5 ========================================================================

Saravanakumar Arumugam 1 Nov 22, 2021
A cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.

Motan Overview Motan is a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services. Related

Weibo R&D Open Source Projects 5.8k Dec 20, 2022
Tars is a high-performance RPC framework based on name service and Tars protocol, also integrated administration platform, and implemented hosting-service via flexible schedule.

TARS - A Linux Foundation Project TARS Foundation Official Website TARS Project Official Website WeChat Group: TARS01 WeChat Offical Account: TarsClou

THE TARS FOUNDATION PROJECTS 9.6k Jan 1, 2023
📈 Get insights about your Laravel or Lumen Project

Laravel Stats Get insights about your Laravel or Lumen Project. Installing The easiest way to install the package is by using composer. The package re

Stefan Zweifel 1.6k Dec 30, 2022
Lumen on Docker - Skeleton project with Nginx, MySQL & PHP 8 | Aws ECS, Google Kubernates, Azure Container Engine

Docker infrastructure for Lumen Description Microservice Lumen is a starting skeleton based on Docker and Lumen Framework. This project helps to devel

Fabrizio Cafolla 218 Sep 25, 2022
urldecode'ing of all HTTP parameters in Lumen project

Request UrlDecode Description This package is intended to perform urldecode of all HTTP parameters in Lumen project. Lumen for some reason does not do

null 1 Dec 13, 2021