PHPackages                             scorpionslh/cpanel-uapi-php-class - 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. scorpionslh/cpanel-uapi-php-class

ActiveLibrary[API Development](/categories/api)

scorpionslh/cpanel-uapi-php-class
=================================

A class forked from N1ghteyes

039PHP

Since Jul 19Pushed 1y agoCompare

[ Source](https://github.com/scorpionslh/cpanel-uapi-php-class)[ Packagist](https://packagist.org/packages/scorpionslh/cpanel-uapi-php-class)[ RSS](/packages/scorpionslh-cpanel-uapi-php-class/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (1)Used By (0)

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

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

[![GitHub release](https://camo.githubusercontent.com/864730ecd01424eecf3f52b70311c66d7dc92194640799e1ba86e5c659945f10/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f4e31676874657965732f6370616e656c2d554150492d7068702d636c6173732e7376673f7374796c653d666c61742d737175617265)](https://github.com/N1ghteyes/cpanel-UAPI-php-class/releases)

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.

v2.0 is not backwards compatible with v1.x, and will likley undergo a few more changes. See the [changelog](changelog.txt) for details. The class has been renamed to `cpanelAPI`. Some more testing is required.

- Note while this class is not depricated, there is a new Agnostic API class available which will do everything this class does (except 2FA) and works with any RESTful / HTTP API - basically anything thats not SOAP.

Usage
-----

[](#usage)

If you choose to use this class, please Star it in Github. This gives me a better idea of the number of users and those effected when changes are made.

See the example files, but typical usage takes the form of:

### Instantiate the class

[](#instantiate-the-class)

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

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://documentation.cpanel.net/display/SDK/UAPI+Functions+-+Mysql%3A%3Aget_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', '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

16

—

LowBetter than 5% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.2% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c4706a1ab48f7256c715ae7f9b22f221ec982658aeb1f8fbdd926d995b92a1a?d=identicon)[marcoshsteixeira](/maintainers/marcoshsteixeira)

---

Top Contributors

[![N1ghteyes](https://avatars.githubusercontent.com/u/5121074?v=4)](https://github.com/N1ghteyes "N1ghteyes (32 commits)")[![marcuspmd](https://avatars.githubusercontent.com/u/1530934?v=4)](https://github.com/marcuspmd "marcuspmd (8 commits)")[![Deltik](https://avatars.githubusercontent.com/u/1364268?v=4)](https://github.com/Deltik "Deltik (2 commits)")

### Embed Badge

![Health badge](/badges/scorpionslh-cpanel-uapi-php-class/health.svg)

```
[![Health](https://phpackages.com/badges/scorpionslh-cpanel-uapi-php-class/health.svg)](https://phpackages.com/packages/scorpionslh-cpanel-uapi-php-class)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

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

A PHP wrapper for Twilio's API

1.6k92.9M272](/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)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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