PHP code example of mtoolkit / mtoolkit-network

1. Go to this page and download the library: Download mtoolkit/mtoolkit-network 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/ */

    

mtoolkit / mtoolkit-network example snippets


class RPCJsonWebService extends MRPCJsonWebService
{
    public function __construct(){}
    
    public function sum($data)
    {
        $response = new MRPCJsonResponse();
        $response->setId( $this->getRequest()->getId() );
        $response->setResult( array( 'sum' => $data['a'] + $data['b'] ) );
        $this->setResponse( $response );
    }
}

$request = new MRPCJsonRequest();
$request->setId(1)
    ->setMethod('sum')
    ->setParams( array('a'=>1, 'b'=>2) );

$client = new MRPCJsonClient($url);
$client->call($request);

$response = $client->getResponse();