# 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 ```bash composer require hyperf/jet ``` # 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: ```php new StreamSocketTransporter(), ProtocolManager::PACKER => new JsonEofPacker(), ProtocolManager::PATH_GENERATOR => new PathGenerator(), ProtocolManager::DATA_FORMATTER => new DataFormatter(), ]); ``` ## 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: ```php [ [$host = '127.0.0.1', $port = 9503], ], ]); ``` ## 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: ```php create($service = 'CalculatorService', $protocol = 'jsonrpc'); ``` When you have the client object, you could call any remote methods via the object, like below: ```php // Call the remote method `add` with arguments `1` and `2`. // The $result is the result of the remote method. $result = $client->add(1, 2); ``` 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: ```php add(1, 2); ```