Server managers connect FOSSBilling to hosting control panels (cPanel, Plesk, DirectAdmin, etc.), enabling automatic account creation, suspension, and management.
File Structure
Section titled “File Structure”Place your manager in:
src/library/Server/Manager/└── YourManager.phpExtend Server_Manager and implement the required methods.
Required Methods
Section titled “Required Methods”The Server_Manager base class defines these methods:
| Method | Purpose |
|---|---|
create() | Create a hosting account |
suspend() | Suspend an account |
unsuspend() | Unsuspend an account |
cancel() | Cancel/delete an account |
changePassword() | Change account password |
changePackage() | Change hosting plan/package |
Basic Structure
Section titled “Basic Structure”<?php
class Server_Manager_YourManager extends Server_Manager{ public function __construct($options) { parent::__construct($options);
if (!isset($this->config['api_key'])) { throw new Server_Exception('API key is required'); } }
public static function getForm(): array { return [ 'label' => 'YourManager', 'form' => [ 'api_key' => ['text', ['label' => 'API Key']], 'api_secret' => ['password', ['label' => 'API Secret']], ], ]; }
public function create(Server_Account $account): bool { $params = [ 'username' => $account->getUsername(), 'password' => $account->getPassword(), 'domain' => $account->getDomain(), 'package' => $account->getPackage()->getName(), 'email' => $account->getEmail(), ];
$response = $this->apiRequest('create_account', $params);
if ($response['success']) { $account->setUsername($response['username']); return true; }
throw new Server_Exception($response['error'] ?? 'Failed to create account'); }
public function suspend(Server_Account $account): bool { return $this->apiRequest('suspend_account', [ 'username' => $account->getUsername(), ]); }
public function unsuspend(Server_Account $account): bool { return $this->apiRequest('unsuspend_account', [ 'username' => $account->getUsername(), ]); }
public function cancel(Server_Account $account): bool { return $this->apiRequest('delete_account', [ 'username' => $account->getUsername(), ]); }
public function changePassword(Server_Account $account, string $newPassword): bool { return $this->apiRequest('update_password', [ 'username' => $account->getUsername(), 'password' => $newPassword, ]); }
public function changePackage(Server_Account $account, Server_Package $package): bool { return $this->apiRequest('change_package', [ 'username' => $account->getUsername(), 'package' => $package->getName(), ]); }
private function apiRequest(string $action, array $params = []): array { $url = $this->config['api_url'] . '/' . $action;
$ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer ' . $this->config['api_key'], 'Content-Type: application/json', ]);
$response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch);
if ($httpCode !== 200) { throw new Server_Exception('API request failed: ' . $response); }
return json_decode($response, true) ?? []; }}Testing Your Manager
Section titled “Testing Your Manager”- Add your server in System → Hosting plans and servers
- Create a hosting plan linked to your server
- Create a hosting product using that plan
- Place a test order
- Verify account creation in the control panel
- Test suspend, unsuspend, and cancellation
Resources
Section titled “Resources”Server_Manager— Base class with inline docs- Existing managers in
src/library/Server/Manager/
Getting Help
Section titled “Getting Help”Join our Discord for assistance with your server manager.