Development

sfJSONRPCPlugin

You must first sign up to be able to contribute.

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

Todo

  • implement access control for individual methods
  • update method description to current working draft spec

Attachments