Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Feb 21, 2017
2 parents c4a3d0e + 76fde32 commit 6dc1fed
Showing 1 changed file with 61 additions and 10 deletions.
71 changes: 61 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,42 @@ composer require quickj/dubbo-php-client

###Usage
```php
require_once "src/dubboClient.php";
use \dubbo\dubboClient;

// options for register consumer
// 注册消费者配置

$options= array(
"registry_address" => "127.0.0.1:2181"
"registry_address" => "127.0.0.1:2181",
'version' => '1.0.0',
'group' =>null,
'protocol' => 'jsonrpc'
);
$dubboCli = new dubboClient($options);
$HelloService = $dubboCli->getService("com.dubbo.demo.HelloService","1.0.0",null);
$ret = $HelloService->hello("dubbo php client");
echo $ret;

//try is must
try {
$dubboCli = new dubboClient($options);
$testService = $dubboCli->getService("com.dubbo.demo.HelloService");
$ret = $testService->hello("dubbo php client");
$mapRet = $testService->mapEcho();
$objectRet = $testService->objectEcho();

var_dump($ret);
var_dump($mapRet);
var_dump($objectRet);

} catch (Exception $e) {
print($e->getMessage());
}

/* getService method support 2 way. If the forceVgp = true, It will assign the function parameter to service version,group and protocol. Default way is assign the $options configs to these.
getService支持两种方式调用。如果forceVgp=true, 该方法将使用传参来绑定服务的版本号,组和协议。默认方式是使用$options数组里的配置绑定。
*/
$testServiceWithvgp = $dubboCli->getService("com.dubbo.demo.HelloService","1.0.0",null, $forceVgp = true);
var_dump($testServiceWithvgp->hello("this request from vgp"));

```
```
###example
```bash
Expand Down Expand Up @@ -79,16 +105,41 @@ composer require quickj/dubbo-php-client
```
###如何使用
```php
require_once "src/dubboClient.php";
use \dubbo\dubboClient;

// options for register consumer
// 注册消费者配置

$options= array(
"registry_address" => "127.0.0.1:2181"
"registry_address" => "127.0.0.1:2181",
'version' => '1.0.0',
'group' =>null,
'protocol' => 'jsonrpc'
);
$dubboCli = new dubboClient($options);
$HelloService = $dubboCli->getService("com.dubbo.demo.HelloService","1.0.0",null);
$ret = $HelloService->hello("dubbo php client");
echo $ret;

//try is must
try {
$dubboCli = new dubboClient($options);
$testService = $dubboCli->getService("com.dubbo.demo.HelloService");
$ret = $testService->hello("dubbo php client");
$mapRet = $testService->mapEcho();
$objectRet = $testService->objectEcho();

var_dump($ret);
var_dump($mapRet);
var_dump($objectRet);

} catch (Exception $e) {
print($e->getMessage());
}

/* getService method support 2 way. If the forceVgp = true, It will assign the function parameter to service version,group and protocol. Default way is assign the $options configs to these.
getService支持两种方式调用。如果forceVgp=true, 该方法将使用传参来绑定服务的版本号,组和协议。默认方式是使用$options数组里的配置绑定。
*/
$testServiceWithvgp = $dubboCli->getService("com.dubbo.demo.HelloService","1.0.0",null, $forceVgp = true);
var_dump($testServiceWithvgp->hello("this request from vgp"));

```
###例子
```bash
Expand Down

0 comments on commit 6dc1fed

Please sign in to comment.