您的位置 首页 php

分享一个好用的Laravel 扩展(laravel-hprose)

本文给大家分享一个好用的Laravel 扩展(laravel-hprose),该扩展是基于 hprose/hprose-php 开发的 Laravel 扩展。

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

https://github.com/fendui/laravel-hprose

安装

composer require fendui/laravel-hprose dev-master

配置

config/app.php 注册 HproseServiceProvider

'providers' => [    .....    \fendui\HproseServiceProvider::class ]

创建配置和demo路由文件

php artisan vendor:publish --provider="fendui\HproseServiceProvider"

服务端 方法注入和类注入

\fendui\Facades\HproseRoute::add(function () {    return 'service hello';}, 'hello');\fendui\Facades\HproseRoute::add(\fendui\demoService::class);

启动rpc服务

php artisan hprose:socket

客户端调用

$uris =['tcp://127.0.0.1:1314'];$client = new \fendui\Clients\SocketClient($uris, false);$client->hello()$client->fendui_demoService->kan()需要配置配置'client' => [  'tcp_uris' => [      'tcp://127.0.0.1:1314',  ],    'async' => false],app('hprose.socket.client')->hello()

demo 查看注册的方法

http://127.0.0.1:8000/rpc

可以通过路由查看调用方式

http://127.0.0.1:8000/rpc/kanhttp://127.0.0.1:8000/rpc/demo/sayhttp://127.0.0.1:8000/rpc/demo/kanhttp://127.0.0.1:8000/rpc/demo/can

相关推荐:最新的五个Laravel视频教程

文章来源:智云一二三科技

文章标题:分享一个好用的Laravel 扩展(laravel-hprose)

文章地址:https://www.zhihuclub.com/24922.shtml

关于作者: 智云科技

热门文章

网站地图