Creating Server Modules
Guide to creating server provisioning modules
Creating a Server Module
Server modules handle automated provisioning and management of hosting accounts on servers (e.g., cPanel, Plesk, custom panels).
Step 1: Create Module Directory
/modules/servers/yourserver/
Step 2: Create module.json
{
"name": "yourserver",
"display_name": "Your Server",
"description": "Server provisioning integration",
"version": "1.0.0"
}
Step 3: Create Server Class
Create YourserverServer.php implementing ModuleInterface.
Required Actions
Server modules should implement these actions:
create_account: Create a new hosting accountsuspend_account: Suspend a hosting accountunsuspend_account: Unsuspend a hosting accountterminate_account: Permanently delete a hosting accountget_account_info: Get account informationchange_password: Change account passwordget_packages: Get available hosting packages
Example Implementation
public function execute($action, $params = []) {
switch ($action) {
case 'create_account':
return $this->createAccount($params);
case 'suspend_account':
return $this->suspendAccount($params);
case 'unsuspend_account':
return $this->unsuspendAccount($params);
case 'terminate_account':
return $this->terminateAccount($params);
default:
return ['success' => false, 'error' => 'Unknown action'];
}
}
private function createAccount($params) {
$domain = $params['domain'] ?? '';
$username = $params['username'] ?? '';
$password = $params['password'] ?? '';
$package = $params['package'] ?? '';
// Call server API to create account
// Return: ['success' => true, 'account_id' => '...']
return [
'success' => true,
'account_id' => 'acc123'
];
}
Example: cPanel Server
See /modules/servers/cpanel/CpanelServer.php for a complete reference implementation.