Installation
composer require fendui/laravel-hprose dev-master
Configuration
Register HproseServiceProvider inconfig/app.php
'providers' => [ ..... \fendui\HproseServiceProvider::class ]
Create configuration and demo routing files
php artisan vendor:publish --provider="fendui\HproseServiceProvider"
Server-side method injection and class injection
\fendui\Facades\HproseRoute::add(function () { return 'service hello'; }, 'hello'); \fendui\Facades\HproseRoute::add(\fendui\demoService::class);
Start rpc service
php artisan hprose:socket
Client call
$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 View registered method
http://127.0.0.1:8000/rpc
You can view the calling method through routing
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