A simple PHP project to make API requests on your cPanel installation. This allows you to call modules inside the installation and interact with them to add, show or list data such as domains, e-mail accounts, databases and so on.
The project makes use of UAPI. Therefore it is required to have a cPanel installation with at least version 42.
Clone the repository first:
git clone firstname.lastname@example.org:eliashaeussler/cpanel-requests.git cd cpanel-requests
Install the dependencies (
composer needs to be installed for this):
Now point your web server/virtual host to the
public directory of your cloned project and you should be able to access
In order to access your cPanel instance and set some configuration settings, it's necessary to create a user-specific environment file:
cp .env.dist .env
Add user functions
index.php serves as entry point for code execution. It includes all PHP files which are
located inside the
src/includes directory and executes them. Files starting with an underscore (e.g.
won't be included.
Each include file should return a closure which executes the user-specific code. The authenticated cPanel instance
should be passed as first argument. An example file can be found in
This project ships an example user function which reads sub domains from the cPanel instance and prints them as HTML
list. For this, a domain name can be specified as
DOMAIN_NAME in your
.env file. If it's set, only sub domains
matching this domain name will be printed, otherwise sub domains of the current server name will be printed. Setting
* will print all sub domains for all available domain names.
The project includes a console which can be used to execute several functions from the command line. It's located in the root directory of the project:
# General usage ./console.php # Clear expired cookie files ./console.php clear:cookie ./console.php clear:cookie --lifetime 604800 # Clear log files ./console.php clear:logfile