Laravel Hprose Extension: Installation, Configuration, and Usage Guide

This guide explains how to install, configure, and use the Laravel‑Hprose extension built on hprose‑php, covering Composer installation, service provider registration, publishing configuration, defining server methods, starting the RPC socket server, and client‑side invocation with code examples.

php Courses
php Courses
php Courses
Laravel Hprose Extension: Installation, Configuration, and Usage Guide

This article introduces the Laravel‑Hprose extension built on hprose/hprose‑php, providing RPC capabilities for Laravel applications.

Installation is performed via Composer: composer require fendui/laravel-hprose dev-master.

After installation, register the service provider in config/app.php by adding \fendui\HproseServiceProvider::class to the 'providers' array.

Publish the configuration and demo routes with

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

.

Define server‑side methods either by closure or class injection using

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

and

\fendui\Facades\HproseRoute::add(\fendui\demoService::class);

.

Start the RPC socket server via php artisan hprose:socket.

On the client side, create a socket client with the server URI, e.g.,

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

, and configure the client in the 'client' config section.

Demo endpoints can be accessed through URLs such as http://127.0.0.1:8000/rpc and specific method routes like http://127.0.0.1:8000/rpc/kan, http://127.0.0.1:8000/rpc/demo/say, etc.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

RPCComposerLaravelHprose
php Courses
Written by

php Courses

php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.