keensoen/cpanel-api

cPanel API,让您连接并执行cpanel中的多个常见任务

v1.2 2021-03-29 18:26 UTC

This package is auto-updated.

Last update: 2024-09-29 06:02:58 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

Laravel CPanel UAPI包

请考虑给项目加星标以表示您的喜爱和支持。

此Laravel包允许您通过CPanel UAPI连接和管理基于CPanel的托管。

一些实际用途包括

  • 创建数据库、子域名、电子邮件账户等
  • 创建数据库用户
  • 设置任何用户的数据库权限
  • 列出指定域的所有电子邮件账户
  • 检查电子邮件账户大小
  • 在需要时增加电子邮件配额
  • 在必要时删除电子邮件账户

更多关于CPanel UAPI的信息请参阅CPanel UAPI指南

安装

步骤 1) 安装包

使用以下composer命令安装包

composer require keensoen/cpanel-api 

或者将keensoen/cpanel-api添加到composer.json的要求中

{
    ...
    "require": {
        ...
        "keensoen/cpanel-api": "^1.0"
    },
}

更新composer

$ composer update

步骤 2) 发布配置

运行以下命令

php artisan vendor:publish --provider="Keensoen\CPanelApi\CPanelApiServiceProvider"

步骤 3) 在.env中设置CPanel详细信息

CPANEL_DOMAIN= 
CPANEL_PORT=
CPANEL_API_TOKEN=
CPANEL_USERNAME=

或者

$cpanel = new CPanel($cpanel_domain=null, $cpanel_api_token=null, $cpanel_username=null, $protocol='https', $port=2083);

要生成CPANEL_API_TOKEN,请登录到CPanel >> 安全 >> 管理API令牌 >> 创建

用法及可用方法

请确保您已导入

use Keensoen\CPanelApi\CPanel;

获取CPanel中所有电子邮件账户的列表

$cpanel = new CPanel();  
$response = $cpanel->getEmailAccounts();

创建电子邮件账户

您的密码必须超过八个字符,并且应包含字母数字和符号。例如

$cpanel = new CPanel()
$username = 'john.dansy';
$password = 'ideaHeals@#12';
$response = $cpanel->createEmailAccount($username, $password);

删除电子邮件账户

您必须传递完整的电子邮件地址才能删除该账户。

$cpanel = new CPanel()
$response = $cpanel->deleteEmailAccount('john.dansy@example.com');

获取电子邮件账户磁盘使用量

您必须传递您想要获取磁盘使用的电子邮件地址。

$cpanel = new CPanel()
$response = $cpanel->getDiskUsage('john.dansy@example.com');

增加电子邮件账户配额

您必须传递您想要获取磁盘使用的电子邮件地址。

$cpanel = new CPanel()
$email = 'john.dansy@example.com';
$quota = 1024;
$response = $cpanel->increaseQuota($email,$quota);

创建数据库

数据库名称应使用cpanel用户名作为前缀 cpanelusername_databasename

如果您的CPanel用户名是surf,则您的数据库名称应该是surf_website

$cpanel = new CPanel();
$response = $cpanel->createDatabase('cpanelusername_databasename');

更多详细信息请参阅CPanel UAPI - Mysql::create_database

删除数据库

$cpanel = new CPanel();  
$response = $cpanel->deleteDatabase('cpanelusername_databasename');

CPanel UAPI - Mysql::delete_database

获取CPanel中所有数据库的列表

$cpanel = new CPanel();  
$response = $cpanel->listDatabases();

创建数据库用户

$cpanel = new CPanel();  
$response = $cpanel->createDatabaseUser($username, $password);

删除数据库用户

$cpanel = new CPanel();  
$response = $cpanel->deleteDatabaseUser($username);

在数据库上给数据库用户所有权限

$cpanel = new CPanel();  
$response = $cpanel->setAllPrivilegesOnDatabase($database_user, $database_name);

使用CPanel UAPI方法

您也可以使用以下方法调用CPanel UAPI中所有可用的方法

$cpanel = new CPanel();  
$response = $cpanel->callUAPI($Module, $function, $parameters);

例如,如果您想添加新的ftp账户,文档可在CPanel UAPI - Ftp::add_ftp中找到,那么请使用以下方法

$cpanel = new CPanel();  
$Module = 'Ftp';
$function = 'add_ftp';
$parameters_array = [
'user'=>'ftp_username',
'pass'=>'ftp_password', //make sure you use strong password
'quota'=>'42',
];
$response = $cpanel->callUAPI($Module, $function, $parameters_array);

变更日志

有关最近更改的更多信息,请参阅CHANGELOG

贡献

有关详细信息,请参阅CONTRIBUTING

安全性

如果您发现任何安全相关的问题,请通过sesughagbadu@yahoo.com发送电子邮件,而不是使用问题跟踪器。

致谢

许可

MIT许可(MIT)。请参阅许可文件以获取更多信息。