PHP code example of akhaled / cpanel-api

1. Go to this page and download the library: Download akhaled/cpanel-api 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/ */

    

akhaled / cpanel-api example snippets


$domain = 'example.com';

Akhaled\CPanelAPI\Facades\CPanelAPI::domain()->create($domain);

$domain = 'example.com';

Akhaled\CPanelAPI\Facades\CPanelAPI::domain()->delete($domain);

$domain = 'example.com';
$subdomain = 'example';
$dir = 'public_html'; // optional, default config('cpanel.default_dir')

Akhaled\CPanelAPI\Facades\CPanelAPI::addonDomain()->create($domain, $subdomain, $dir);

$domain = 'example.com';
$subdomain = 'example_base.com';

Akhaled\CPanelAPI\Facades\CPanelAPI::addonDomain()->delete($domain, $subdomain);

// subdomain: beta.example.com
$domain = 'example.com';
$subdomain = 'beta';
$dir = 'public_html'; // optional, default config('cpanel.default_dir')

Akhaled\CPanelAPI\Facades\CPanelAPI::subdomain($domain)->create($subdomain, $dir);

// subdomain: beta.example.com
$domain = 'example.com';
$subdomain = 'beta';

Akhaled\CPanelAPI\Facades\CPanelAPI::subdomain($domain)->delete($subdomain);

$db_name = 'fresh_database';

Akhaled\CPanelAPI\Facades\CPanelAPI::database()->create($db_name);

$db_name = 'my_old_database';

Akhaled\CPanelAPI\Facades\CPanelAPI::database()->delete($db_name);

$db_user = 'my_old_user_name';
$db_password = 'raw_password';

Akhaled\CPanelAPI\Facades\CPanelAPI::databaseUser()->create($db_user, $db_password);

$db_user = 'user_name';
$db_name = 'database';

Akhaled\CPanelAPI\Facades\CPanelAPI::databaseUser()->addToDatabase($db_user, $db_name);

    $db_user = 'my_old_user_name';

    Akhaled\CPanelAPI\Facades\CPanelAPI::databaseUser()->delete($db_user);