-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.php
43 lines (35 loc) · 1.05 KB
/
demo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
/**
* DemoController
*
* @link https://www.myziyue.com/
* @contact [email protected]
* @license http://license.coscl.org.cn/MulanPSL/
*/
namespace App\Controller;
use \Hyperf\Context\ApplicationContext;
use Myziyue\DubboClient\Pool\PoolFactory;
class DemoController extends Controller
{
/**
* @var ResponseInterface
*/
protected $response;
public function index()
{
$serverName = "com.myziyue.Demo.HelloService";
$dubboClient = ApplicationContext::getContainer()->get(PoolFactory::class)->getPool("default")->createConnection();
$dubboClient->setAppVersion('1.0.0');
$dubboClient->setAppGroup('default');
$dubboClient->setAppServices($serverName);
// 获取服务并调用服务提供的方法hello
$helloService = $dubboClient->get();
$result = $helloService->hello("world");
return $this->response->json([
'code' => 0,
'message' => 'success',
'data' => $result
]);
}
}