Laravel Package for CPanel UAPI
Please consider starring the project to show your ❤️ and support.
This laravel package allows you to connect and manage you CPanel based hosting using CPanel UAPI.
Some practical usages are:
- Create database, sub domains, emails accounts etc
- Create database users
- Set privileges on database of any user
- List all email account of the specified domain
- Check email account size
- Increase email quota when need arises
- Delete email account when necessary
Learn more about at CPanel UAPI
Use following composer command to install the package
composer require keensoen/cpanel-api
or
Add keensoen/cpanel-api
as a requirement to composer.json
:
{
...
"require": {
...
"keensoen/cpanel-api": "^1.0"
},
}
Update composer:
$ composer update
Run following command:
php artisan vendor:publish --provider="Keensoen\CPanelApi\CPanelApiServiceProvider"
CPANEL_DOMAIN=
CPANEL_PORT=
CPANEL_API_TOKEN=
CPANEL_USERNAME=
or
$cpanel = new CPanel($cpanel_domain=null, $cpanel_api_token=null, $cpanel_username=null, $protocol='https', $port=2083);
To generate CPANEL_API_TOKEN
, login to the CPanel >> SECURITY >> Manage API Tokens >> Create
.
Make sure you import:
use Keensoen\CPanelApi\CPanel;
$cpanel = new CPanel();
$response = $cpanel->getEmailAccounts();
Your password must be eight character above and should contain alphanumeric and symbols. For example
$cpanel = new CPanel()
$username = 'john.dansy';
$password = 'ideaHeals@#12';
$response = $cpanel->createEmailAccount($username, $password);
You will have to pass a full email address to be able to delete the account.
$cpanel = new CPanel()
$response = $cpanel->deleteEmailAccount('john.dansy@example.com');
You will have to pass a full email address of which you want to get disk usage.
$cpanel = new CPanel()
$response = $cpanel->getDiskUsage('john.dansy@example.com');
You will have to pass a full email address of which you want to get disk usage.
$cpanel = new CPanel()
$email = 'john.dansy@example.com';
$quota = 1024;
$response = $cpanel->increaseQuota($email,$quota);
Database name should be prefixed with cpanel username cpanelusername_databasename
If your CPanel username is surf
then your database name
| should be surf_website
.
$cpanel = new CPanel();
$response = $cpanel->createDatabase('cpanelusername_databasename');
Find More Details at CPanel UAPI - Mysql::create_database
$cpanel = new CPanel();
$response = $cpanel->deleteDatabase('cpanelusername_databasename');
CPanel UAPI - Mysql::delete_database
$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);
You can also call all the method available at CPanel UAPI using following method:
$cpanel = new CPanel();
$response = $cpanel->callUAPI($Module, $function, $parameters);
for example if you want to add new ftp
account, documetation is available at CPanel UAPI - Ftp::add_ftp then use the method as represented below:
$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);
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email sesughagbadu@yahoo.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.