PHP code example of oploshka / rpc-core

1. Go to this page and download the library: Download oploshka/rpc-core library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oploshka / rpc-core example snippets


$MethodStorage  = new \Oploshka\Rpc\MethodStorage();

$MethodStorage->add('TestMethod1', '\\RpcMethodPath\\TestMethod1');
$MethodStorage->add('TestMethod2', '\\RpcMethodPath\\TestMethod2');

// init MultipartJsonRpc_v0_1
$rpcInitData = [
  'methodStorage'   => $MethodStorage                                           ,
  'reform'          => new \Oploshka\Reform\ReformDebug()                            ,
  'dataLoader'      => new \Oploshka\RpcDataLoader\PostMultipartFieldJson()     ,
  'dataFormatter'   => new \Oploshka\RpcDataFormatter\MultipartJsonRpc_v0_1()   ,
  'returnFormatter' => new \Oploshka\RpcReturnFormatter\MultipartJsonRpc_v0_1() ,
  'responseClass'   => new \Oploshka\Rpc\Response()                             ,
];
$Rpc = new \Oploshka\Rpc\Core($rpcInitData);
$Rpc->applyHeaderSettings();
$Rpc->applyPhpSettings();

$returnJson = $Rpc->startProcessingRequest();

echo $returnJson;