Coder Social home page Coder Social logo

motan-php's Introduction

Motan-PHP

License https://travis-ci.org/weibocom/motan-php.svg?branch=master

Overview

Motan is a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.

This project is the PHP Motan implementation. Provides PHP motan client.

Quick Start

Installation

Using composer:

Just clone this project and add it to your composer.json.

WithOut Composer:

If you didn't use composer for php libraries management, you would install motan-php by hand,like git clone, please check the demo at motan-example .

Usage:

we need an defined constant MOTAN_PHP_ROOT for load the motan php libs. Just like the demo does.

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

The quick start gives very basic example of running client and server on the same machine. For the detailed information about using and developing Motan, please jump to Documents. the demo case is in the main/ directory

Motan server

We use Weibo-Mesh to support a PHP Server, Weibo-Mesh is a local agent writen in Golang. But not only a agent, Wei-Mesh take the ability as service governance. There is an example at motan-example

As a CGI agent to php-fpm

  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

As a HTTP agent to any HTTP Server

  http-mesh-example-helloworld:
    path: com.weibo.motan.HelloWorldService
    export: "motan2:9990"
    provider: http
    HTTP_REQUEST_METHOD: GET
    HTTP_URL: http://10.211.55.3:9900/http_server
    basicRefer: mesh-server-basicService

Motan Client

Here is a simple example about Motan Client, it will call a remote service provider by Weibo-Mesh Testhelper, you can find more example in the phpt tests, you can just run ./run.sh to find more.

$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());
}

Contributors

License

Motan is released under the Apache License 2.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.