-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
readme file updated
- Loading branch information
tmudriy
committed
Dec 4, 2014
1 parent
e293c13
commit 27c109f
Showing
4 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace cranetm\JsonRpc2; | ||
namespace JsonRpc2; | ||
|
||
use Yii; | ||
use yii\base\InlineAction; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
namespace cranetm\JsonRpc2; | ||
namespace JsonRpc2; | ||
|
||
class Exception extends \yii\base\Exception | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,50 @@ | ||
yii2-json-rpc-2.0 | ||
JSON RPC 2.0 for Yii2 | ||
================= | ||
Easiest way to use in 4 steps: | ||
1) Install via composer | ||
in ./composer.json add into 'require' section | ||
~~~php | ||
"cranetm/yii2-json-rpc-2.0": "dev-master" | ||
~~~ | ||
and in console/terminal run | ||
~~~php | ||
composer update | ||
~~~ | ||
|
||
2) Use namespace in your controller | ||
~~~php | ||
use \JsonRpc2\Controller; | ||
~~~ | ||
OR change extends class to | ||
~~~php | ||
class ServicesController extends \JsonRpc2\Controller | ||
{ | ||
//BODY | ||
} | ||
~~~ | ||
|
||
3) Create actions in Yii-style like | ||
~~~php | ||
public function actionUpdate($message) | ||
{ | ||
return ["message" => $message]; | ||
} | ||
~~~ | ||
|
||
4) Make json request to controller (used pretty urls without index.php) | ||
~~~php | ||
http://yoursite/services | ||
~~~ | ||
with data | ||
~~~php | ||
{ | ||
"jsonrpc": "2.0", | ||
"id": 1, | ||
"method": "update", | ||
"params": ["hello world"] | ||
} | ||
~~~ | ||
and response will be | ||
~~~php | ||
{"jsonrpc":"2.0","id":1,"result":{"message":"hello world"}} | ||
~~~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters