PHP code example of motan / motan-php

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

    

motan / motan-php example snippets


define('MOTAN_PHP_ROOT', './vendor/motan/motan-php/src/Motan/');

$app_name = 'search';
$service = 'com.weibo.HelloMTService';
$group = 'motan-demo-rpc';
$remote_method = 'HelloW';
$params = ['idevz'=>'for weibo-mesh'];
$cx = new Motan\MClient( $app_name );
$request = new \Motan\Request($service, $remote_method, $params);
$request->setGroup($group);
try{
    $res = $cx->doCall($request);
} catch(Exception $e) {
    var_dump($e->getMessage());
}
yaml
  cgi-mesh-example-helloworld:
    path: com.weibo.motan.HelloWorldService
    export: "motan2:9991"
    provider: cgi
    CGI_HOST: 10.211.55.3
    CGI_PORT: 9000
    CGI_REQUEST_METHOD: GET
    CGI_SCRIPT_FILENAME: /motan-examples/php-server/index.php
    CGI_DOCUMENT_ROOT: /motan-examples/php-server
    basicRefer: mesh-server-basicService