PHPackages                             jagdish-j-p/cpanel-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. jagdish-j-p/cpanel-api

ActiveLibrary[API Development](/categories/api)

jagdish-j-p/cpanel-api
======================

PHP Implementation of CPANEL APIS i.e. UAPI, API2 to manage functions of CPANEL via PHP i.e. managing database, managing database users.

v1.1.0(2y ago)11702MITPHP

Since May 26Pushed 2y ago2 watchersCompare

[ Source](https://github.com/Jagdish-J-P/cpanel-api)[ Packagist](https://packagist.org/packages/jagdish-j-p/cpanel-api)[ Fund](https://paypal.me/jagdishjptl)[ Fund](https://www.buymeacoffee.com/jagdish.j.ptl)[ RSS](/packages/jagdish-j-p-cpanel-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

cPanel UAPI and API2 PHP class
==============================

[](#cpanel-uapi-and-api2-php-class)

PHP class to provide an easy-to-use interface with cPanel's UAPI and API2. Uses PHP magic functions to provide a simple and powerful interface.

Become a sponsor
----------------

[](#become-a-sponsor)

[![](.github/assets/support.png)](https://github.com/sponsors/Jagdish-J-P)

Your support allows me to keep this package free, up-to-date and maintainable. Alternatively, you can **[spread the word!](http://twitter.com/share?text=I+am+managing+my+cpanel+using+this+cool+PHP+package&url=https://github.com/jagdish-j-p/cpanel-api&hashtags=PHP,Laravel,CPANEL)**

Installation
------------

[](#installation)

```
composer require jagdish-j-p/cpanel-api
```

Usage
-----

[](#usage)

Basic Authentication using cpanel username and password

```
use JagdishJP\CPanelAPI\CPanelAPI;
use JagdishJP\CPanelAPI\AuthType;

$cPanel = new cpanelAPI('cpanel_username', 'cpanel_password', 'cpanel.example.com');
```

Authentication using cpanel username and API Token. You can create token from `Security -> Manage API Tokens`. Visit [Manage API Token](https://docs.cpanel.net/cpanel/security/manage-api-tokens-in-cpanel/#overview)

```
use JagdishJP\CPanelAPI\CPanelAPI;
use JagdishJP\CPanelAPI\AuthType;

$cPanel = new cpanelAPI('cpanel_username', 'cpanel_api_token', 'cpanel.example.com', AuthType::TOKEN);
```

The API we want to use and the Module (also called Scope) are now protected and are set by `__get()`.

The request layout looks like this: `$cPanel->api->method->Module->request(args[])`

The `->method` part should be replaced with `->get` for GET requests and `->post` for POST requests, or omitted to default to GET requests.

As an example, suppose we want to use the UAPI to call the [Mysql::get\_server\_information](https://api.docs.cpanel.net/openapi/cpanel/operation/Variables-get_server_information/) function:

```
$response = $cPanel->uapi->Mysql->get_server_information();
var_dump($response);
```

Now that we have set both the API *and* the Module, we can call other functions within this API and Module without specifying them again:

```
$response = $cPanel->create_database(['name' => $cPanel->user.'_MyDatabase']);
var_dump($response);
```

We can also change the Module scope without respecifying the API. Note that the Module call is case-sensitive.

```
$response = $cPanel->SSL->list_certs();
```

#### File upload example

[](#file-upload-example)

```
$cPanel = new cpanelAPI($username, $password, $hostname);
$cPanel->uapi->post->Fileman
       ->upload_files(['dir' => REMOTE_PATH_RELATIVE_TO_HOME,
                       'file-1' => new CURLFile(LOCAL_PATH_TO_FILE)
                       ]);
```

### API2

[](#api2)

API2 is used in exactly the same way as the UAPI

```
$cPanel = new cpanelAPI('user', 'password', 'cpanel.example.com');
```

For example, suppose we want to use the API2 to add a subdomain:

```
$response = $cPanel->api2->SubDomain->addsubdomain(['rootdomain' => 'domain.com', 'domain' => 'sub']);
var_dump($response);
```

### Two-Factor Authentication

[](#two-factor-authentication)

To use this class on a cPanel instance with two-factor authentication (2FA), you need to pass the secret into the class constructor:

```
$cPanel = new cpanelAPI('user', 'password', 'cpanel.example.com', AuthType::BASIC, 'secret');
```

The secret can be found on the 2FA setup page. See [Two-Factor Authentication for cPanel – Configure two-factor authentication](https://documentation.cpanel.net/display/ALD/Two-Factor+Authentication+for+cPanel#Two-FactorAuthenticationforcPanel-Configure2FA) for details.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~77 days

Total

2

Last Release

1001d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4e7c021b8f19406056e9a24ec8d268cec00f1a9d77bd72d8cc5cb0a6fbc6a178?d=identicon)[Jagdish-J-P](/maintainers/Jagdish-J-P)

---

Top Contributors

[![Jagdish-J-P](https://avatars.githubusercontent.com/u/20887370?v=4)](https://github.com/Jagdish-J-P "Jagdish-J-P (6 commits)")

### Embed Badge

![Health badge](/badges/jagdish-j-p-cpanel-api/health.svg)

```
[![Health](https://phpackages.com/badges/jagdish-j-p-cpanel-api/health.svg)](https://phpackages.com/packages/jagdish-j-p-cpanel-api)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[microsoft/microsoft-graph

The Microsoft Graph SDK for PHP

65723.5M95](/packages/microsoft-microsoft-graph)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
