You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://packagist.org/packages/wa72/jsonrpc-bundle)
7
7
8
8
9
-
JsonRpcBundle is a bundle for Symfony 2 and 3 that allows to easily build a JSON-RPC server for web services using [JSON-RPC 2.0] (http://www.jsonrpc.org/specification).
9
+
JsonRpcBundle is a bundle for Symfony that allows to easily build a JSON-RPC server for web services using
Copy file name to clipboardexpand all lines: Resources/doc/index.rst
+22-8
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,16 @@
1
+
=============
1
2
JsonRpcBundle
2
3
=============
3
4
4
5
JsonRpcBundle is a bundle for Symfony 2.7 and up that allows to easily build a JSON-RPC server for web services using `JSON-RPC 2.0`_.
5
6
6
-
The bundle contains a controller that is able to expose methods of any service registered in the Symfony service container as a JSON-RPC web service. The return value of the service method is converted to JSON using `jms\_serializer`_.
7
+
The bundle contains a controller that is able to expose methods of any public service registered in the Symfony service container as a JSON-RPC web service. The return value of the service method is converted to JSON using `jms\_serializer`_.
7
8
8
9
Of course, it doesn't simply expose all your services' methods to the public, but only those explicitely mentioned in the configuration. And service methods cannot be called by it's original name but by an alias to be defined in the configuration.
9
10
10
11
11
12
Installation
12
-
------------
13
+
============
13
14
14
15
1. Add "wa72/jsonrpc-bundle" as requirement to your composer.json
15
16
@@ -27,9 +28,13 @@ Installation
27
28
Your JSON-RPC web service will then be available in your project calling the /jsonrpc/ URL.
28
29
29
30
Configuration
30
-
-------------
31
+
=============
31
32
32
33
You must configure which functions of the services registered in the Service Container will be available as web services.
34
+
There are two methods how to do this:
35
+
36
+
Method 1: Expose single methods from any service via yaml configuration
Starting with v0.4.0, it is also possible to fully expose all methods of a service by tagging it with ``wa72\_jsonrpc.exposable``.
70
79
All public methods of services tagged with 'wa72\_jsonrpc.exposable' can be called via JSON-RPC. The method name
71
80
to be used in the RPC call is "service\:method", i.e. the name of the service and the method separated by colon.
72
81
82
+
83
+
Notes
84
+
=====
85
+
73
86
**New in Version 0.5.0**: It is now possible to call methods that require objects as parameters (in previous versions
74
87
only methods with scalar and array parameters could be called).
75
88
That's why *JMSSerializerBundle is now a required dependency*.
@@ -78,10 +91,11 @@ For this to work, the following conditions must be met:
78
91
- The method parameters must be correctly type hinted
79
92
- The classes used as parameters must contain `jms\_serializer @Type annotations for their properties <http://jmsyst.com/libs/serializer/master/reference/annotations#type>`_
80
93
94
+
81
95
Testing
82
-
-------
96
+
=======
83
97
84
-
The bundle comes with a test service. If you have imported the bundle's routing to ``/jsonrpc`` (see above)
98
+
The bundle comes with a simple test service. If you have imported the bundle's routing to ``/jsonrpc`` (see above)
85
99
register the test service in your DI container:
86
100
87
101
.. code-block:: yaml
@@ -105,10 +119,10 @@ and you should get the following answer:
0 commit comments