sfJSONRPCPlugin
The sfJSONRPCPlugin is a plugin that provides a simple way to create JSON-RPC services with symfony.
Change Log
v0.0.2: replace getRemoteMethods() with PHP Reflection API, so that public methods are automatically exported
v0.0.1: first public release
Installation
- Install the plugin
symfony plugin-install http://plugins.symfony-project.com/sfJSONRPCPlugin
Usage
Create a new action class that is derived from sfJSONRPCAction instead of sfAction.
class myJSONRPCServiceAction extends sfJSONRPCServiceAction {
}
All public methods of this class that are not inherited from sfJSONRPCAction will be callable via JSON-RPC calls. Note that inherited methods will never be exported, even if you override them in the action class itself.
public function method1($arg1, $arg2) {
return true;
}
public function method2() {
return array('this' => 'that');
}
The return value of the remote method will be JSON encoded and returned to the JSON-RPC client.
If you make a simple GET request for the action, you will get the method description for this particular JSON-RPC service. The method description is generated automatically.
Bibliography
- JSON-RPC homepage: http://json-rpc.org/
- Current JSON-RPC draft: http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html
Todo
- implement access control for individual methods
- update method description to current working draft spec
Attachments
- sfJSONRPCPlugin-0.0.1.tgz (9.5 kB) -
first public release of sfJSONRPCPlugin
, added by aferber on 02/14/07 00:25:31. - sfJSONRPCPlugin-0.0.2.tgz (9.7 kB) - added by aferber on 01/29/08 16:04:25.