Download the PHP package hyperf/jet without Composer
On this page you can find all versions of the php package hyperf/jet. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package jet
English | 中文
Jet, by Hyperf
Jet is a unification model RPC Client, built-in JSONRPC protocol, available to running in ALL PHP environments, including PHP-FPM and Swoole/Hyperf environments.
Also will built-in gRPC and Tars protocols in future.
Installation
Quickstart
Register protocol
Register the protocol is not necessary, but you could manage the protocols more easily by using ProtocolManager.
You cloud register any protocol by Hyperf\Jet\ProtocolManager
, per protocol basically including Transporter, Packer, DataFormatter and PathGenerator, you could register a JSONRPC protocol like below:
If you use consul, you could register a JSONRPC protocol like below:
Register service
Register the service is not necessary, but you could manage the services more easily by using ServiceManager.
After you registered a protocol to Hyperf\Jet\ProtocolManager
, you could bind the protocol with any services by Hyperf\Jet\ServiceManager
, like below:
Call RPC method
Call by ClientFactory
After you registered the protocol and service, you could get your service client via Hyperf/Jet/ClientFactory
, like below:
When you have the client object, you could call any remote methods via the object, like below:
If you call a not exist remote method, the client will throw an Hyperf\Jet\Exception\ServerException
exception.
Call by custom client
You could also create a custom client class which extends Hyperf\Jet\AbstractClient
, to call the remote methods via the client object.
For example, you want to define a RPC client for CalculatorService
with jsonrpc
protocol, you could create a CalculatorService
class firstly, like below:
If use Consul service, you can use it in the following way.
Now, you could use this class to call the remote method directly, like below: