Server
Server
Abstract base class for RPC servers.
class Server extends \Hazaar\RPC\ControllerProvides core logic for handling remote procedure calls (RPC), method registration, and protocol encoder management. Subclasses must implement specific RPC methods and register protocol encoders for supported content types.
Properties
registeredMethods
protected array $registeredMethodsencoders
private array $encodersMethods
__construct
Constructs a new RPC server instance and registers public methods and trait initializers.
public __construct(Request $request): voidParameters
| Parameter | Type | Description |
|---|---|---|
$request | Request | the incoming application request |
__toString
Returns the class name of the RPC server instance.
public __toString(): stringhandle
Handles an incoming RPC request and returns the encoded response.
public handle(): ResponseValidates encoders and registered methods, parses the request, invokes the target method, and encodes the result or error.
registerMethod
Registers a public method for RPC invocation.
public registerMethod(\ReflectionMethod $reflectionMethod): voidParameters
| Parameter | Type | Description |
|---|---|---|
$reflectionMethod | \ReflectionMethod | the method to register |
getEncoder
Retrieves the encoder instance for the specified content type.
public getEncoder(?string $contentType): EncoderParameters
| Parameter | Type | Description |
|---|---|---|
$contentType | string | the content type for which to retrieve the encoder |
registerEncoder
Registers an encoder for a specific content type.
protected registerEncoder(string $contentType, Encoder $encoder): voidParameters
| Parameter | Type | Description |
|---|---|---|
$contentType | string | the content type to associate with the encoder |
$encoder | Encoder | the encoder instance to register |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:24 +0000