1. Go to this page and download the library: Download chuckbartowski/cpanel-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use ChuckBartowski\CpanelSdk\Cpanel;
final class MailboxProvisioner
{
public function __construct(private readonly Cpanel $cpanel)
{
}
public function provision(string $localPart, string $domain, string $password): void
{
$this->cpanel->email()->create($localPart, $domain, $password, quotaMb: 512);
}
}
use ChuckBartowski\CpanelSdk\Whm;
final class HostingAccountManager
{
public function __construct(private readonly Whm $whm)
{
}
public function open(string $username, string $domain): void
{
$this->whm->accounts()->create($username, $domain, [
'plan' => 'starter',
'contactemail' => '[email protected]',
]);
}
public function suspendForNonPayment(string $username): void
{
$this->whm->accounts()->suspend($username, 'unpaid invoice');
}
}
use ChuckBartowski\CpanelSdk\Client\CpanelClient;
use ChuckBartowski\CpanelSdk\Cpanel;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\JsonMockResponse;
$http = new MockHttpClient(new JsonMockResponse(['status' => 1, 'data' => []]));
$cpanel = new Cpanel(new CpanelClient('host', 'user', 'token', 2083, true, 30.0, $http));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.