Download the PHP package mops1k/json-rpc-bundle without Composer
On this page you can find all versions of the php package mops1k/json-rpc-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package json-rpc-bundle
JSON-RPC Server bundle
This bundle provide an easy way to implement json-rpc server with fully specification supporting. Bundle supports multiple procedure calls in one request as described in specification.
JSON-RPC specification is fully compatible with CQRS architecture
Install
Import route declaration in your routes:
Or add your own paths by template:
Usage
To create method you have to create invokable class with
attribute \JsonRpcBundle\Attribute\AsRpcMethod
, where methodName
constructor
parameter must contain method name. Example:
Contract request DTO
Bundle provide possibility to provide params to your DTO class. For these feature you have to add
attribute \JsonRpcBundle\Attribute\RpcMethodContract
.
DTO passed supports validation through symfony/validator.
Example:
Validation for method params without contract
If you don't want to use DTO, you still able to validate method parameters and set its groups. In this case you need to
implement your method class
from \JsonRpcBundle\MethodResolver\ValidateMethodParametersInterface
.
Example:
Notification
Json rpc supports notification requests what does not return any response. To make your method as notification, just
add void
in __invoke
return type hint.
Example:
Namespace
Bundle supports method namespacing. To set method namespace, use \JsonRpcBundle\Attribute\AsRpcMethod::$namespace
attribute parameter.
Example:
To fetch namespaced method you can call it by method name (namespace.methodName
) or call to path /rpc/{namespace}
and use regular method name.
Examples:
-
Call to
/rpc
: - Call to
/rpc/user
:
This feature also supports bath requests.
API Documentation
Bundle supports documentation semi-auto generation
thru nelmio/api-doc-bundle.
By default documentation generate params from method parameters, method contract. If you need more specific params
documentation,
just use OA\Property
attribute. If you need specific response result, then
use \JsonRpcBundle\ApiDoc\Attribute\Result
attribute (set array of OA\Property
inside $properties
parameter).
Object responses auto-generated to documentation by it's describing inside class.
All versions of json-rpc-bundle with dependencies
symfony/framework-bundle Version ^6.4 || ^7.0
symfony/property-access Version ^6.4 || ^7.0
symfony/serializer Version ^6.4 || ^7.0
symfony/validator Version ^6.4 || ^7.0