hecsedli / cakephpjsonrpcserver
CakePHP 3.x JSON-RPC server
Installs: 33
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 1
Open Issues: 0
Type:cakephp-plugin
Requires
- php: >=5.6.0
- cakephp/cakephp: ~3.6
Requires (Dev)
- phpunit/phpunit: ~4.1
This package is not auto-updated.
Last update: 2025-05-11 09:06:52 UTC
README
CakePHP 3.x JSON-RPC server
Original idea: James Watts https://github.com/jameswatts/cake-jsonrpc
Requirements
- CakePHP 3.6+
- PHP 5.6+
Installation
You can install using composer.
composer require hecsedli/cakephpjsonrpcserver
// config/bootstrap.php Plugin::load('JSONRPCServer', ['bootstrap' => true]);
Implementation
Add the component to your controller
public $components = ["JSONRPCServer.JsonrpcServer"];
public function user($request) { if (isset($request->params->userId)) { return $this->User->findById($request->params->userId); } else { throw new Exception('No user ID was specified', 123); } );
JSON request
{ "jsonrpc": "2.0", "method": "user", "params": { "userId": 5 }, "id": "test" }