Skip to content

Commit

Permalink
composer package changes;
Browse files Browse the repository at this point in the history
readme file updated
  • Loading branch information
tmudriy committed Dec 4, 2014
1 parent e293c13 commit 27c109f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/JsonRpc2/Controller.php → JsonRpc2/Controller.php
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;
Expand Down
2 changes: 1 addition & 1 deletion src/JsonRpc2/Exception.php → JsonRpc2/Exception.php
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
{
Expand Down
50 changes: 49 additions & 1 deletion README.md
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"}}
~~~
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "tmudryi/yii2-json-rpc-2.0",
"name": "cranetm/yii2-json-rpc-2.0",
"description": "JSON RPC 2.0 for Yii2",
"license": "GNU",
"authors": [
Expand All @@ -15,6 +15,6 @@
},
"autoload":
{
"psr-0": { "cranetm": "src/" }
"psr-0": { "JsonRpc2": "/" }
}
}

0 comments on commit 27c109f

Please sign in to comment.