PHP code example of joba / cloud-dns

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

    

joba / cloud-dns example snippets




declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  [email protected]
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Controller;

use AlibabaCloud\SDK\Alidns\V20150109\Alidns;
use AlibabaCloud\SDK\Alidns\V20150109\Models\DescribeDnsProductInstancesRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Joba\CloudDns\Factory;
use Hyperf\Di\Annotation\Inject;

class IndexController extends Controller
{
    #[Inject]
    protected Factory $factory;

    public function index()
    {
        /** @var Alidns $client */
        $client = $this->factory->get('aliyun')->client();

        $describeDnsProductInstanceRequest = new DescribeDnsProductInstancesRequest();
        $runtime = new RuntimeOptions([]);

        $res = $client->describeDnsProductInstancesWithOptions($describeDnsProductInstanceRequest, $runtime);

        return $this->response->success($res);
    }
}




declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  [email protected]
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Controller;

use Joba\CloudDns\Factory;
use Hyperf\Di\Annotation\Inject;
use TencentCloud\Dnspod\V20210323\Models\DescribeUserDetailRequest;

class IndexController extends Controller
{
    #[Inject]
    protected Factory $factory;

    public function index()
    {
        /** @var Alidns $client */
        $client = $this->factory->get('aliyun')->client();

        $req = new DescribeUserDetailRequest();

        $params = [];
        $req->fromJsonString(json_encode($params));

        $res = $client->DescribeUserDetail($req);

        return $this->response->success($res);
    }
}




declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  [email protected]
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Controller;

use Cloudflare\API\Adapter\Guzzle;
use Cloudflare\API\Endpoints\User;
use Joba\CloudDns\Factory;
use Hyperf\Di\Annotation\Inject;

class IndexController extends Controller
{
    #[Inject]
    protected Factory $factory;

    public function index()
    {
        /** @var Guzzle $client */
        $client = $this->factory->get('cloudflare')->client();
        
        $user = new User($client);

        return $this->response->success($user->getUserID());
    }
}

shell
php bin/hyperf.php vendor:publish joba/cloud-dns