|
1 | | -# component-creator |
| 1 | +# DNS云服务统一 API |
2 | 2 |
|
| 3 | +## 安装 |
| 4 | + |
| 5 | +```shell |
| 6 | +composer require gemini/dns-cloud |
| 7 | +``` |
| 8 | + |
| 9 | +## 使用 |
| 10 | + |
| 11 | +创建配置 |
| 12 | + |
| 13 | +```shell |
| 14 | +php bin/hyperf.php vendor:publish gemini/dns-cloud |
3 | 15 | ``` |
4 | | -composer create-project hyperf/component-creator |
| 16 | + |
| 17 | +设置环境变量 |
| 18 | + |
| 19 | +```dotenv |
| 20 | +DNS_CLOUD_ALIYUN_ACCESS_KEY_ID="xxx" |
| 21 | +DNS_CLOUD_ALIYUN_ACCESS_SECRET="xxx" |
| 22 | +``` |
| 23 | + |
| 24 | +编写测试代码,我们直接把代码全部写到控制器里,开发者请按照实际情况酌情处理 |
| 25 | + |
| 26 | +```php |
| 27 | +<?php |
| 28 | + |
| 29 | +declare(strict_types=1); |
| 30 | +/** |
| 31 | + * This file is part of Hyperf. |
| 32 | + * |
| 33 | + * @link https://www.hyperf.io |
| 34 | + * @document https://hyperf.wiki |
| 35 | + * @contact group@hyperf.io |
| 36 | + * @license https://github.com/hyperf/hyperf/blob/master/LICENSE |
| 37 | + */ |
| 38 | + |
| 39 | +namespace App\Controller; |
| 40 | + |
| 41 | +use AlibabaCloud\SDK\Alidns\V20150109\Alidns; |
| 42 | +use AlibabaCloud\SDK\Alidns\V20150109\Models\DescribeDnsProductInstancesRequest; |
| 43 | +use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions; |
| 44 | +use Gemini\DnsCloud\Factory; |
| 45 | +use Hyperf\Di\Annotation\Inject; |
| 46 | + |
| 47 | +class IndexController extends Controller |
| 48 | +{ |
| 49 | + #[Inject] |
| 50 | + protected Factory $factory; |
| 51 | + |
| 52 | + public function index() |
| 53 | + { |
| 54 | + /** @var Alidns $client */ |
| 55 | + $client = $this->factory->get('aliyun')->client(); |
| 56 | + |
| 57 | + $describeDnsProductInstanceRequest = new DescribeDnsProductInstancesRequest(); |
| 58 | + $runtime = new RuntimeOptions([]); |
| 59 | + |
| 60 | + $res = $client->describeDnsProductInstancesWithOptions($describeDnsProductInstanceRequest, $runtime); |
| 61 | + |
| 62 | + return $this->response->success($res); |
| 63 | + } |
| 64 | +} |
| 65 | + |
5 | 66 | ``` |
6 | | -# dns-cloud |
|
0 commit comments