sergeyfast / eazy-jsonrpc
PHP JSON-RPC 2.0 Server/Client Implementation with SMD & Swagger support
Installs: 64 064
Dependents: 0
Suggesters: 0
Security: 0
Stars: 62
Watchers: 8
Forks: 21
Open Issues: 2
Requires
- php: >=7.2.0
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^7.3
- netresearch/jsonmapper: ^4.0
Requires (Dev)
- phpunit/phpunit: 4.8.*
README
PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD
Server
SMD Schema available via /server.php?smd
Public Namespace
- Inherits your exposed class from BaseJsonRpcServer or create
new BaseJsonRpcServer( $instance );
$server->Execute();
Multiple Namespaces
- Create
new BaseJsonRpcServer();
- Call
$server->RegisterInstance( $instance, $namespace )
as many times as you need $server->Execute();
Client
- Generate Client from SMD Schema from generator/
php JsonRpcClientGenerator.php <smd-file> <class-name>
- Use it:
$client = <class-name>::GetInstance(<url>);
try {
$result = $client->Method();
} catch (BaseJsonRpcException $e) {
// work with exception
}
Client with typed returns by rpcgen
- Generate Client from SMD Schema with rpcgen and save it to
RpcClient.php
- Use it:
$client = RpcClient::GetInstance(<url>);
try {
$result = $client->Method();
} catch (BaseJsonRpcException $e) {
// work with exception
}
Doc
- cd generator
php SmdToSwaggerConverter.php 'http://eazyjsonrpc/tests/example-server.php?smd' eazyjsonrpc ../doc/swagger.json
- open http://eazyjsonrpc/doc/