Add a control panel
A control panel connects through a server manager: one PHP class in library/Server/Manager/ of
the ClientFence directory. The file name and the class name match: ExamplePanel.php holds
Server_Manager_ExamplePanel, which extends Server_Manager. Use a name no built-in panel uses,
so updates never replace your file. Built in: Enhance, cPanel/WHM, Plesk, DirectAdmin, CWP, HestiaCP and
Custom (see their guides under Hosting and domains).
A module can also carry the file in its own Server/Manager/ folder; it is
then available while the module is active.
The server manager
Section titled “The server manager”getForm() names the panel and lists the credential fields the server form asks for: username,
password or accesshash, each with your own label. Their values, the server’s Hostname and
its Connection Port are in $this->_config (host, port). Each account method gets a Server_Account with the username,
password, domain, client and hosting plan (getPackage()). Throw a Server_Exception when the
panel refuses: staff see its message on the order and under Failed actions.
declare(strict_types=1);
class Server_Manager_ExamplePanel extends Server_Manager{ public static function getForm(): array { return [ 'label' => 'Example Panel', 'form' => [ 'credentials' => [ 'fields' => [ [ 'name' => 'accesshash', 'type' => 'text', 'label' => 'API token', 'placeholder' => 'A token from Example Panel with account permissions.', 'required' => true, 'secret' => true, ], ], ], ], ]; }
public function getLoginUrl(?Server_Account $account = null): string { return 'https://' . $this->_config['host'] . '/login'; }
public function getResellerLoginUrl(?Server_Account $account = null): string { return $this->getLoginUrl($account); }
public function testConnection(): bool { $this->call('GET', 'status');
return true; }
public function createAccount(Server_Account $account): bool { $this->call('POST', 'accounts', [ 'username' => $account->getUsername(), 'password' => $account->getPassword(), 'domain' => $account->getDomain(), 'plan' => $account->getPackage()->getName(), 'email' => $account->getClient()->getEmail(), ]);
return true; }
public function synchronizeAccount(Server_Account $account): Server_Account { $remote = $this->call('GET', 'accounts/' . $account->getUsername()); $account->setSuspended($remote['suspended']);
return $account; }
public function suspendAccount(Server_Account $account): bool { $this->call('POST', 'accounts/' . $account->getUsername() . '/suspend');
return true; }
public function unsuspendAccount(Server_Account $account): bool { $this->call('POST', 'accounts/' . $account->getUsername() . '/unsuspend');
return true; }
public function cancelAccount(Server_Account $account): bool { $this->call('DELETE', 'accounts/' . $account->getUsername());
return true; }
public function changeAccountPackage(Server_Account $account, Server_Package $package): bool { $this->call('PUT', 'accounts/' . $account->getUsername(), ['plan' => $package->getName()]);
return true; }
public function changeAccountPassword(Server_Account $account, string $newPassword): bool { $this->call('PUT', 'accounts/' . $account->getUsername(), ['password' => $newPassword]);
return true; }
// Changes this panel does not offer: the admin area shows the message. public function changeAccountUsername(Server_Account $account, string $newUsername): bool { throw new Server_Exception('Example Panel cannot change usernames.'); }
public function changeAccountDomain(Server_Account $account, string $newDomain): bool { throw new Server_Exception('Example Panel cannot change the main domain.'); }
public function changeAccountIp(Server_Account $account, string $newIp): bool { throw new Server_Exception('Example Panel cannot change IP addresses.'); }
private function call(string $method, string $path, array $body = []): array { $response = $this->getHttpClient()->request($method, 'https://' . $this->_config['host'] . '/api/' . $path, [ 'auth_bearer' => $this->_config['accesshash'], 'json' => $method === 'GET' ? null : $body, ]); if ($response->getStatusCode() >= 400) { throw new Server_Exception('Example Panel: ' . $response->getContent(false)); }
return $response->toArray(); }}getHttpClient() and getLog() come from Server_Manager.
Install it
Section titled “Install it”- Copy the file to
library/Server/Manager/and make the web server user its owner. - Go to System → Hosting Plans and Servers, open the Hosting Servers tab and select New Server.
- For Server Manager, choose Example Panel, fill in the server’s details and save. Then select Test Connection.
- Make a hosting plan whose name matches the plan on the panel, and use it in a product.
For complete examples, read Directadmin.php, Hestia.php and Whm.php in the same folder.

