I do not know where you add these codes, whmcs is an external script
Example
use \HansAdema\MofhClient\Client;
// Create a new API client with your API credentials.
$client = Client::create([
'apiUsername' => 'your_api_username',
'apiPassword' => 'your_api_password',
'plan' => 'my_plan', // Optional, you can define it here or define it with the createAccount call.
]);
// Create a request object to create the request.
$request = $client->createAccount([
'username' => 'abcdefgh', // A unique, 8 character identifier of the account.
'password' => 'password123', // A password to login to the control panel, FTP and databases.
'domain' => 'userdomain.example.com', // Can be a subdomain or a custom domain.
'email' => '
[email protected]', // The email address of the user.
'plan' => 'my_plan', // Optional, you can submit a hosting plan here or with the Client instantiation.
]);
// Send the API request and keep the response.
$response = $request->send();
// Check whether the request was successful.
if ($response->isSuccessful()) {
echo 'You can login as: ' . $response->getVpUsername();
} else {
echo 'Failed to create account: ' . $response->getMessage();
}