Download the PHP package jagdish-j-p/cpanel-api without Composer
On this page you can find all versions of the php package jagdish-j-p/cpanel-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jagdish-j-p/cpanel-api
More information about jagdish-j-p/cpanel-api
Files in jagdish-j-p/cpanel-api
Package cpanel-api
Short Description PHP Implementation of CPANEL APIS i.e. UAPI, API2 to manage functions of CPANEL via PHP i.e. managing database, managing database users.
License MIT
Informations about the package cpanel-api
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
Your support allows me to keep this package free, up-to-date and maintainable. Alternatively, you can spread the word!
Installation
Usage
Basic Authentication using cpanel username and password
Authentication using cpanel username and API Token. You can create token from Security -> Manage API Tokens. Visit Manage API 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 function:
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:
We can also change the Module scope without respecifying the API. Note that the Module call is case-sensitive.
File upload example
API2
API2 is used in exactly the same way as the UAPI
For example, suppose we want to use the API2 to add a subdomain:
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:
The secret can be found on the 2FA setup page. See Two-Factor Authentication for cPanel – Configure two-factor authentication for details.