mohammadv184/arvancloud

ArvanCloud API 的 PHP 库

v1.1.1 2021-12-19 21:33 UTC

This package is auto-updated.

Last update: 2024-09-19 23:19:44 UTC


README

ArvanCloud

PHP ArvanCloud API

Latest Stable Version Total Downloads Latest Unstable Version Build Status License

PHP ArvanCloud API 的 PHP 库。此包支持 PHP 7.3+

对于 Laravel 集成,您可以使用 mohammadv184/arvancloud-laravel 包。

内容列表

服务列表

安装

通过 Composer

composer require mohammadv184/arvancloud

配置

a. 将 config/arvancloud.php 复制到您的项目中某个位置。(您也可以在 vendor/mohammadv184/arvancloud/config/arvancloud.php 路径中找到它)。

b. 在配置文件中,您可以为所有服务设置配置,并且还可以在运行时更改配置。

选择您在应用程序中希望使用的认证类型。

    'auth'=> [
        'default'  => 'ApiKey', //Set default Auth Type
        'UserToken'=> '',
        'ApiKey'   => '',//User API Key available in arvancloud panel
    ],
    ...

然后在服务数组中填写该服务的凭据。

'services' => [
    'cdn' => [
        'baseUrl'  => 'https://napi.arvancloud.com/cdn/4.0/',
        'domain'   => 'your_domain.com',// Fill in the credentials here.
        'endpoints'=> [...],
    ],
    ...
]
    ...   

c. 实例化 ArvanCloud 类,并将以下配置传递给它

    use Mohammadv184\ArvanCloud\ArvanCloud;

    // load the config file from your project
    $config = require('path/to/arvancloud.php');

    $arvanCloud= new ArvanCloud($config);

如何使用服务

如何使用 ArvanCloud 服务。

CDN

在进行任何操作之前,您需要 ArvanCloud 类

在您的代码中,使用它如下

// At the top of the file.
use Mohammadv184\ArvanCloud\ArvanCloud;
...

// Create new ArvanCloud.
$arvanCloud = new ArvanCloud($config);

// Using Cdn Service
$arvanCloud->cdn()->domain('your_domain.com')->get();

// more Example
// 1
$arvanCloud->cdn()->domain()->get('your_domain.com');
// 2 
$arvanCloud->cdn()->domain()->all();
// 3
$arvanCloud->cdn()->cache('your_domain.com')->purge();
// 4
$arvanCloud->cdn()->dns()->delete('Dns_id','your_domain.com')
                    ->getMessage();

可用方法

  • 域名 :
    • all() : 获取所有域名
    • create(string $domain) : 创建新域名。
    • get(string $domain = null) : 获取域名设置
    • delete(string $domain = null) : 删除域名。
  • 缓存 :
    • get(string $domain = null) : 获取域名缓存设置。
    • update(array $data, string $domain = null) : 更新域名缓存设置。
    • purge(array $urls = null, string $domain = null) : 清除域名缓存。
  • DNS :
    • all() : 获取所有域名 DNS。
    • create(string $domain) : 创建新域名 DNS。
    • get(string $domain = null) : 获取域名 DNS 设置。
    • update(string $id, array $data, string $domain = null) : 更新域名 DNS 设置。
    • delete(string $domain = null) : 删除域名 DNS。
    • cloud(string $id, bool $status = true, string $domain = null) : 更新域名 DNS 云状态。
    • import($zoneFile, string $domain = null) : 使用 BIND 文件导入 DNS 记录
  • SSL :
    • get(string $domain = null) : 获取域名 SSL 设置。
    • update(string $sslType, string $domain = null) : 更新域名 SSL 设置。

致谢

许可协议

MIT 许可协议 (MIT)。有关更多信息,请参阅 许可文件