关于php:基于-hprosehprosephp-开发的-Laravel-扩展laravelhprose

https://github.com/fendui/lar…

装置

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/kan
http://127.0.0.1:8000/rpc/demo/say
http://127.0.0.1:8000/rpc/demo/kan
http://127.0.0.1:8000/rpc/demo/can

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理