Download the PHP package chuckbartowski/cpanel-sdk without Composer

On this page you can find all versions of the php package chuckbartowski/cpanel-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cpanel-sdk

# πŸ–₯ cPanel & WHM SDK for PHP **A modern, fully typed PHP SDK for driving cPanel (UAPI + API2) and WHM (API 1).** [![PHP Version](https://img.shields.io/badge/PHP-%3E%3D%208.2-777BB4?logo=php&logoColor=white)](https://www.php.net/) [![Symfony](https://img.shields.io/badge/Symfony-6.4%20%7C%207.x-000000?logo=symfony&logoColor=white)](https://symfony.com/) [![Tests](https://img.shields.io/badge/tests-23%20passing-brightgreen?logo=github)](tests/) [![Packagist](https://img.shields.io/packagist/v/chuckbartowski/cpanel-sdk?label=packagist&color=f28d1a)](https://packagist.org/packages/chuckbartowski/cpanel-sdk) [![License](https://img.shields.io/badge/license-MIT-yellow)](LICENSE) *Email Β· DNS Β· MySQL Β· SSL Β· FTP Β· Files Β· Accounts Β· Resellers Β· Packages Β· AutoSSL Β· Backups* [Installation](#installation) Β· [Quick Start](#quick-start-plain-php) Β· [API Reference](#api-reference) Β· [Error Handling](#error-handling)

Framework-agnostic core β€” usable from any PHP project, script, or worker β€” with an optional bundle for first-class Symfony integration. Authenticated with API tokens, typed exceptions, and a comment-free, strictly typed codebase (PHP 8.2+, declare(strict_types=1) everywhere).


Table of Contents


Features

Requirements

Dependency Version
PHP >= 8.2
cPanel/WHM any version supporting API tokens (v64+)
Symfony 6.4 LTS or 7.x β€” optional, only for the bundle integration

You will need at least one of:

Installation

The package is published on Packagist:

Quick Start (plain PHP)

No framework required β€” build the clients and go:

Client constructor signature (identical for both clients):

Symfony Integration (optional)

A ready-made bundle wires everything into the container. Register it:

Then create config/packages/cpanel_sdk.yaml:

And the matching environment variables:

Configuration reference

Key Type Default Description
host string required Hostname of the cPanel/WHM server (no scheme, no port)
verify_ssl bool true TLS peer/host verification; disable only for self-signed dev servers
timeout float 30.0 Per-request timeout in seconds
cpanel.username string '' cPanel account name
cpanel.token string '' cPanel API token
cpanel.port int 2083 cPanel TLS port
whm.username string '' WHM user (usually root or a reseller)
whm.token string '' WHM API token
whm.port int 2087 WHM TLS port

The cpanel and whm sections are independent β€” configure only the side you need. Calling a client with missing credentials throws an AuthenticationException immediately, before any network request is made.

The bundle reuses your application's http_client service when available (so scoped clients, retry strategies, and profiler integration all apply), and falls back to a native client otherwise.

Architecture

Design decisions:

Usage

Standalone, instantiate the facades as shown in the Quick Start. In Symfony, both facades are autowirable in controllers, services, commands, and message handlers.

The Cpanel facade

The Whm facade

Generic calls (escape hatch)

Any endpoint not covered by a module remains reachable:

cpanelUapi() runs a UAPI function as any cPanel account through the WHM token β€” the standard pattern for hosting control panels where only the root/reseller token is stored.

API Reference

Every method returns an Error Handling). Named arguments are shown where they improve readability.

Email

$cpanel->email() β€” UAPI Email module.

Method Underlying function Notes
accounts(?string $domain = null) list_pops_with_disk Includes disk usage per mailbox
create(string $localPart, string $domain, string $password, int $quotaMb = 0) add_pop 0 = unlimited quota
delete(string $localPart, string $domain) delete_pop
changePassword(string $localPart, string $domain, string $password) passwd_pop
setQuota(string $localPart, string $domain, int $quotaMb) edit_pop_quota
forwarders(?string $domain = null) list_forwarders
addForwarder(string $domain, string $localPart, string $destination) add_forwarder
deleteForwarder(string $address, string $forwarder) delete_forwarder
mailDirUsage(string $localPart, string $domain) get_pop_quota

Domains

$cpanel->domains() β€” UAPI DomainInfo + API2 SubDomain / AddonDomain / Park.

Method Underlying function
list() UAPI DomainInfo::list_domains
data(?string $domain = null) UAPI domains_data / single_domain_data
addSubdomain(string $subdomain, string $rootDomain, ?string $documentRoot = null) API2 SubDomain::addsubdomain
deleteSubdomain(string $subdomain, string $rootDomain) API2 SubDomain::delsubdomain
addAddonDomain(string $newDomain, string $subdomain, string $documentRoot) API2 AddonDomain::addaddondomain
deleteAddonDomain(string $domain, string $subdomain) API2 AddonDomain::deladdondomain
park(string $domain) / unpark(string $domain) API2 Park

MySQL

$cpanel->mysql() β€” UAPI Mysql module.

Method Underlying function
databases() / users() list_databases / list_users
createDatabase(string $name) / deleteDatabase(string $name) create_database / delete_database
renameDatabase(string $oldName, string $newName) rename_database
createUser(string $name, string $password) / deleteUser(string $name) create_user / delete_user
setPassword(string $user, string $password) set_password
grant(string $user, string $database, string $privileges = 'ALL PRIVILEGES') set_privileges_on_database
revoke(string $user, string $database) revoke_access_to_database
addHost(string $host) add_host

Remember that cPanel prefixes database and user names with the account name (myaccount_app).

FTP

$cpanel->ftp() β€” UAPI Ftp module: accounts(), create(), delete() (with optional home-dir destruction), changePassword(), setQuota(), setHomeDir().

SSL

$cpanel->ssl() β€” UAPI SSL module: certificates(), installedHosts(), install(), delete(), generateKey(), generateCsr().

Files

$cpanel->files() β€” UAPI Fileman for content, API2 Fileman::fileop for filesystem operations: list(), read(), write(), info(), mkdir(), delete(), copy(), move(), chmod(), extract(), emptyTrash().

DNS (cPanel zone editor)

$cpanel->dns() β€” API2 ZoneEdit module. addRecord() automatically maps the value to the right parameter name for the record type (address for A/AAAA, cname for CNAME, txtdata for TXT, exchange for MX…).

API2 zone records are addressed by line number in the zone file; always re-fetch records after a mutation before addressing another line.

Stats & quotas

$cpanel->stats() β€” quota() (UAPI Quota), bars() (UAPI StatsBar, configurable display list), bandwidth() (API2 Stats::getmonthlybandwidth).

WHM β€” Accounts

$whm->accounts() β€” the account lifecycle, WHM API 1.

Method Underlying function Notes
list(?string $search = null, string $searchType = 'user') listaccts searchType: user, domain, owner, ip, package
summary(string $user) accountsummary
create(string $username, string $domain, array $options = []) createacct options: plan, password, contactemail, quota, …
remove(string $user, bool $keepDns = false) removeacct Destructive
suspend(string $user, string $reason = '') / unsuspend(string $user) suspendacct / unsuspendacct
changePassword(string $user, string $password) passwd
modify(string $user, array $options) modifyacct
changePlan(string $user, string $plan) changepackage
domainOwner(string $domain) domainuserdata
createUserSession(string $user, string $service = 'cpaneld') create_user_session One-click SSO URL into the user's cPanel
bandwidth(?string $user = null, ?string $month = null, ?string $year = null) showbw Bandwidth usage, optionally filtered
limitBandwidth(string $user, int $limitMb) limitbw

WHM β€” Resellers

$whm->resellers() β€” the full reseller lifecycle for multi-tier hosting.

Method Underlying function Notes
list() listresellers
stats(string $reseller) resellerstats Disk/bandwidth totals across owned accounts
accounts(string $reseller) acctcounts Used/limit account counts
promote(string $user, bool $ownsSelf = false) setupreseller Turns an existing account into a reseller
demote(string $user) unsetupreseller
setLimits(string $user, array $limits) setresellerlimits e.g. enable_account_limit, account_limit, diskspace_limit
setPackageLimit(string $user, string $package, bool $allowed, ?int $number = null) setresellerpackagelimit Restrict which plans a reseller may sell
setAcls(string $reseller, array $acls) setacls Fine-grained privilege grants
setMainIp(string $user, string $ip) setresellermainip
setNameservers(string $user, array $nameservers) setresellernameservers
suspendAccounts(string $reseller) / unsuspendAccounts(string $reseller) suspendreseller / unsuspendreseller Suspends the reseller and all owned accounts

WHM β€” Packages

$whm->packages() β€” list(), create(), update(), delete() around listpkgs / addpkg / editpkg / killpkg.

WHM β€” DNS zones

$whm->dnsZones() β€” full zone lifecycle: list(), dump(), create(), delete(), addRecord(), editRecord(), removeRecord(), reset().

WHM β€” IP addresses

$whm->ips() β€” IP pool management for dedicated-IP offers.

Method Underlying function
list() listips
add(string $ip, string $netmask) addips
delete(string $ip) delip
assignToSite(string $domain, string $ip) / assignToUser(string $user, string $ip) setsiteip
usage() get_shared_ip

WHM β€” Security (cPHulk)

$whm->security() β€” brute-force protection management, the bread and butter of hosting support.

Method Underlying function
enableCphulk() / disableCphulk() enable_cphulk / disable_cphulk
whitelist(string $ip, string $comment = '') / blacklist(...) create_cphulk_record
listWhitelist() / listBlacklist() read_cphulk_records
removeFromWhitelist(string $ip) / removeFromBlacklist(string $ip) delete_cphulk_record
unblockBrute(string $ip) flush_cphulk_login_history_for_ips
flushLoginHistory() flush_cphulk_login_history

WHM β€” Backups & restores

$whm->backups() β€” backup configuration and the account restore queue.

Method Underlying function Notes
config() / setConfig(array $settings) backup_config_get / backup_config_set
users() backup_user_list Users with backup metadata
dates() backup_date_list Available restore points
userBackups(string $user) backup_set_list
queueRestore(string $user, string $restorePoint, array $options = []) restore_queue_add_task Defaults: keep IP, restore MySQL/subdomains/mail config
activateRestoreQueue() restore_queue_activate Starts processing queued restores
restoreQueueState() restore_queue_state Poll for progress
clearCompletedRestores() restore_queue_clear_completed_tasks

WHM β€” PHP versions

$whm->php() β€” MultiPHP management per virtual host.

Method Underlying function
installedVersions() php_get_installed_versions
systemDefault() / setSystemDefault(string $version) php_get_system_default_version / php_set_system_default_version
vhostVersions(string ...$vhosts) php_get_vhost_versions
setVhostVersion(string $version, string ...$vhosts) php_set_vhost_versions
handlers(string $version) / setHandler(string $version, string $handler) php_get_handlers / php_set_handler

Versions use EasyApache identifiers (ea-php83), not bare numbers.

WHM β€” SSL & AutoSSL

$whm->autoSsl() β€” server-wide certificate automation plus manual installs with root privileges.

Method Underlying function
providers() / setProvider(string $provider) get_autossl_providers / set_autossl_provider
checkAllUsers() start_autossl_check_for_all_users
checkUser(string $user) start_autossl_check_for_one_user
enableForUser(string $user) / disableForUser(string $user) set_autossl_feature_for_users
installCertificate(string $domain, string $cert, string $key, ?string $caBundle = null) installssl
certificateInfo(string $domain) fetch_ssl_vhosts

WHM β€” Server configuration

$whm->config() β€” Tweak Settings and global server preferences.

Method Underlying function
tweakSetting(string $key, string $module = 'Main') get_tweaksetting
setTweakSetting(string $key, string\|int $value, string $module = 'Main') set_tweaksetting
updatePreferences() / setUpdatePreferences(array $settings) get_update_config / update_updateconf
hostname() / setHostname(string $hostname) gethostname / sethostname
nameserverConfig() nameserverconfig

WHM β€” Server

$whm->server() β€” version(), hostname(), loadAverage(), serviceStatus(), restartService().

Responses

All calls return an immutable ApiResponse that normalizes the three wire formats (UAPI envelope, API2 cpanelresult, WHM metadata):

data() is null-safe: it returns the default when the payload has no such key or when data is not an array.

Error Handling

All SDK exceptions implement CpanelSdkExceptionInterface, so a single catch covers everything:

Exception Thrown when Extras
ApiException The API answered but reported a failure (module methods validate automatically) getErrors(): array, getRaw(): array
AuthenticationException Credentials are missing, or the server answered HTTP 401/403 thrown before any request when credentials are empty
TransportException Network error, TLS failure, timeout, or a non-JSON response body wraps the underlying symfony/http-client exception

To inspect a failed response without exceptions, use the client directly β€” client-level methods return the response as-is:

Testing

The suite runs entirely offline against MockHttpClient:

To test your own services, inject a CpanelClient/WhmClient built with a mock:

Security Notes

WHMCS module

A ready-to-use WHMCS provisioning module ships in whmcs/modules/servers/cpanelsdk/. It automates cPanel account provisioning through WHM using this SDK β€” create, suspend, unsuspend, terminate, change password, change package, and one-click SSO into cPanel.

Install

  1. composer require chuckbartowski/cpanel-sdk in your WHMCS root (so the SDK is autoloaded).
  2. Copy the cpanelsdk folder into <whmcs>/modules/servers/.
  3. In WHMCS, add a server (System Settings Β» Servers) with Type: cPanel (SDK), the WHM hostname, username root, and your WHM API token in the Access Hash field.
  4. Point a product at the server and set the Package config option to the WHM plan name.
Operation WHM function used
Create / Suspend / Unsuspend / Terminate createacct / suspendacct / unsuspendacct / removeacct
Change password / package passwd / changepackage
One-click login create_user_session

License

MIT


All versions of cpanel-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
symfony/http-client Version ^6.4|^7.0
symfony/http-client-contracts Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package chuckbartowski/cpanel-sdk contains the following files

Loading the files please wait ...