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
* Method is not translated to route as an URL. It should contain actual actual module name, controller and route splitted by dots. So if you have a following URL rule:
17
+
`'do-some-stuff' => 'api1/doer/stuff'`
18
+
your method string should not be `'do-some-stuff'`, but `'api1.doer.stuff'`. Remember that you are just remotely calling procedures, which in Yii2 terms are actions.
19
+
* Note that action is called internally which causes some restrictions on them. One of them is that called action has to approve verb which you use originally for making a JSON-RPC call (most probably it will be GET or POST).
20
+
21
+
## Examples
22
+
Entry point:
23
+
```php
24
+
<?php
25
+
26
+
namespace app\controllers;
27
+
28
+
class JsonRpcController extends \georgique\yii2\json-rpc\Controller {
29
+
// Practically you don't need anything else in this controller,
30
+
// unless you want to customize entry point somehow.
31
+
}
32
+
```
33
+
34
+
Controller with target actions which we are going to call:
35
+
```php
36
+
<?php
37
+
namespace app\modules\api1\controllers;
38
+
39
+
class ExampleController extends \yii\web\Controller {
40
+
41
+
42
+
public function actionTry() {
43
+
return "You've got it!";
44
+
}
45
+
46
+
public function actionTryWithParams($foo) {
47
+
return "Params received: \$foo = $foo.";
48
+
}
49
+
50
+
}
51
+
```
52
+
53
+
Now this is how calls and responses will look like:
0 commit comments