1. Go to this page and download the library: Download beziworld/laravel-hestiacp 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/ */
beziworld / laravel-hestiacp example snippets
use Beziworld\HestiaCP\Exceptions\CommandException;
use Beziworld\HestiaCP\Facades\HestiaCP;
class ProvisionHosting implements ShouldQueue
{
public function handle(): void
{
$user = $this->order->username;
try {
HestiaCP::users()->create($user, $password = Str::password(16), $this->order->email, package: 'business');
HestiaCP::domains()->create($user, $this->order->domain);
HestiaCP::dns()->create($user, $this->order->domain, config('hosting.ip'));
HestiaCP::email()->createDomain($user, $this->order->domain);
HestiaCP::email()->createAccount($user, $this->order->domain, 'office', Str::password(16), quotaMb: 2048);
HestiaCP::ssl()->letsEncrypt($user, $this->order->domain, ['www.' . $this->order->domain]);
} catch (CommandException $e) {
// e.g. "Hestia v-add-user failed (E_EXISTS): user john exists"
$this->fail($e);
return;
}
Mail::to($this->order->email)->send(new HostingReady($this->order, $password));
}
}
$users = HestiaCP::users()->all(); // list<User>
$user = HestiaCP::users()->get('john'); // ?User, null when it does not exist
HestiaCP::users()->suspend('john');
HestiaCP::users()->unsuspend('john');
HestiaCP::users()->changePackage('john', 'premium');
HestiaCP::users()->changePassword('john', $newPassword);
HestiaCP::users()->packages(); // packages with their limits
HestiaCP::users()->delete('john'); // with all domains, mail and databases