Download the PHP package timiki/rpc-server-bundle without Composer
On this page you can find all versions of the php package timiki/rpc-server-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download timiki/rpc-server-bundle
More information about timiki/rpc-server-bundle
Files in timiki/rpc-server-bundle
Package rpc-server-bundle
Short Description JSON-RPC server bundle for symfony
License MIT
Informations about the package rpc-server-bundle
JSON-RPC Server bundle for symfony
JSON-RPC is a remote procedure call protocol encoded in JSON. It is a very simple protocol (and very similar to XML-RPC) , defining only a handful of data types and commands. JSON-RPC allows for notifications (data sent to the server that does not require a response) and for multiple calls to be sent to the server which may be answered out of order.
Install
Symfony >= 6.4 || 7.0
Symfony >= 6.0
Deprecated versions
Symfony >= 5.0 use version ^5.0
Symfony >= 4.3 use version ^4.1
Symfony < 4.3 use version ^4.0
Configs
Add methods dir to exclude from autowire
Controller
Default:
You can use you own controller for JSON-RPC request. For example:
or add default JSON-RPC route (default POST to /rpc) to you routing.yml
or controller for different handler (version)
If web site and JSON-RPC server located on a different domain remember about CORS.
Method
Or you can also use __invoke to declare a call method
Inject method execute Context
Attributes
Method
Define class as JSON-RPC method.
Roles
Set roles for access to method. If user not granted for access server return error with message "Method not granted" and code "-32001".
Cache
If define cache in configs it set response lifetime.
Param
Define JSON-RPC params. Use Symfony\Component\Validator\Constraints for validate it.
Execute
Define execute function in class.
or use __invoke
Serialize
For convert output result from method to json in bundle used serializer
Config for serializer:
In bundle include next serializers:
rpc.server.serializer.base - (default) use Symfony serialize to convert result to json rpc.server.serializer.role - use user roles as @Group (@see https://symfony.com/doc/current/components/serializer.html) for control access to output array
Create custom serializer
Here is an example of a simple class for serialization.
And then add custom serializer service id to config
All versions of rpc-server-bundle with dependencies
ext-json Version *
symfony/console Version ^6.0 | ^7.0
symfony/dependency-injection Version ^6.0 | ^7.0
symfony/event-dispatcher Version ^6.0 | ^7.0
symfony/framework-bundle Version ^6.0 | ^7.0
symfony/http-foundation Version ^6.0 | ^7.0
symfony/http-kernel Version ^6.0 | ^7.0
symfony/property-access Version ^6.0 | ^7.0
symfony/serializer Version ^6.0 | ^7.0
symfony/stopwatch Version ^6.0 | ^7.0
timiki/rpc-common Version ^2.0