PHP code example of keensoen / cpanel-api

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

    

keensoen / cpanel-api example snippets


$cpanel = new CPanel($cpanel_domain=null, $cpanel_api_token=null, $cpanel_username=null, $protocol='https', $port=2083);

use Keensoen\CPanelApi\CPanel;

$cpanel = new CPanel();  
$response = $cpanel->getEmailAccounts();

$cpanel = new CPanel()
$username = 'john.dansy';
$password = 'ideaHeals@#12';
$response = $cpanel->createEmailAccount($username, $password);

$cpanel = new CPanel()
$response = $cpanel->deleteEmailAccount('[email protected]');

$cpanel = new CPanel()
$response = $cpanel->getDiskUsage('[email protected]');

$cpanel = new CPanel()
$email = '[email protected]';
$quota = 1024;
$response = $cpanel->increaseQuota($email,$quota);

$cpanel = new CPanel();
$response = $cpanel->createDatabase('cpanelusername_databasename');

$cpanel = new CPanel();  
$response = $cpanel->deleteDatabase('cpanelusername_databasename');

$cpanel = new CPanel();  
$response = $cpanel->listDatabases();

$cpanel = new CPanel();  
$response = $cpanel->createDatabaseUser($username, $password);

$cpanel = new CPanel();  
$response = $cpanel->deleteDatabaseUser($username);

$cpanel = new CPanel();  
$response = $cpanel->setAllPrivilegesOnDatabase($database_user, $database_name);

$cpanel = new CPanel();  
$response = $cpanel->callUAPI($Module, $function, $parameters);

$cpanel = new CPanel();  
$Module = 'Ftp';
$function = 'add_ftp';
$parameters_array = [
'user'=>'ftp_username',
'pass'=>'ftp_password', //make sure you use strong password
'quota'=>'42',
];
$response = $cpanel->callUAPI($Module, $function, $parameters_array);

php artisan vendor:publish --provider="Keensoen\CPanelApi\CPanelApiServiceProvider"