Home / Module Development / Creating Server Modules

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 account
  • suspend_account: Suspend a hosting account
  • unsuspend_account: Unsuspend a hosting account
  • terminate_account: Permanently delete a hosting account
  • get_account_info: Get account information
  • change_password: Change account password
  • get_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.