dsmgid/php-whm-api
最新稳定版本:v1.0.1
Composer 安装命令:
composer require dsmgid/php-whm-api
包简介
WHM API for PHP
README 文档
README
Contents
Installation Guide
To install this package, you can run this code via your terminal
composer require dsmgid/php-cpanel-api
Or update your composer.json by adding this line
"dsmgid/php-cpanel-api":"~1.0"
Then, run this code
composer update
Usage
For example, if you would like to get list accounts of your whm server, you can do this.
<?php $cpanel = new \dsmgid\CpanelPhp\Cpanel([ 'host' => 'https://123.456.789.123:2087', // ip or domain complete with its protocol and port 'username' => 'root', // username of your server, it usually root. 'auth_type' => 'hash', // set 'hash' or 'password' 'password' => 'password', // long hash or your user's password ]); $accounts = $cpanel->listaccts(); // it will returned as array
Functions
Defining Configuration on constructor
This is the example when you want to define your configuration while creating new object
<?php $cpanel = new \dsmgid\CpanelPhp\Cpanel([ 'host' => 'https://123.456.789.123:2087', // required 'username' => 'root', // required 'auth_type' => 'hash', // optional, default 'hash' 'password' => 'password', // required ]);
Usage
For example, you would like to get some list accounts from cPanel/WHM
<?php $accounts = $cpanel->listaccts(); // passing parameters $accounts = $cpanel->listaccts(['searchtype'=>'domain', 'search'=>'', 'exact', 'search'=>'helloworld.com']);
For accessing cPanel API 2, you can use this.
<?php // get bandwidth data of specific cPanel's user $data = $cpanel->cpanel('Bandwidth', 'getbwdata', 'username'); // removing cron line $data = $cpanel->cpanel('Cron', 'remove_line', 'username', ['line'=>1]);
The first parameter must be Module you would like to get, second is function name, and the third is username of cPanel's user. There is fourth arguments, when function has some additional arguments, you can pass it there.
For accessing to cPanel API 1 or cPanel API 2 or UAPI, you can use this.
<?php // get bandwidth data of specific cPanel's user (using cPanel API 2) $data = $cpanel->execute_action('2', 'Bandwidth', 'getbwdata', 'username'); // removing email address (using UAPI) $data = $cpanel->execute_action('3', 'Email', 'delete_pop', 'username', ['email'=>'peter@griffin.com']);
This function is similar to the above, the only difference is that it has added a parameter which indicates the API you want to use (1 = cPanel API 1, 2 = cPanel API 2, 3 = UAPI), the other arguments are the same.
Overriding current configuration
Somehow, you want to override your current configuration. To do this, here is the code
<?php // change username andd (password or hash) $cpanel->setAuthorization($username, $password); // change host $cpanel->setHost($host); // change authentication type $cpanel->setAuthType($auth_type);
Get defined configuration
After you define some of your configuration, you can get it again by calling this functions
<?php // get username $cpanel->getUsername(); // get password $cpanel->getPassword(); // get authentication type $cpanel->getAuthType(); // get host $cpanel->getHost();
Feedback and contribution
This package is free and open source, feel free to fork and report some issue to this package. :-). Have fun
dsmgid/php-whm-api 适用场景与选型建议
dsmgid/php-whm-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 468 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 07 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 dsmgid/php-whm-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dsmgid/php-whm-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 468
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 29
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-07-24