akhaled/cpanel-api

There is no license information available for the latest version (v1.1.5) of this package.

Unofficial api for cpanel

v1.1.5 2022-10-01 18:42 UTC

This package is auto-updated.

Last update: 2024-11-03 23:45:57 UTC


README

Unofficial CPanel wrapper for shared hosting. For Laravel.

Installation

composer require akhaled/cpanel-api

Configuration

Add following configuration to .env file

CPANEL_USER=xxxxxx
CPANEL_PASSWORD=xxxxx
CPANEL_HOST=123.456.789
CPANEL_SKIN=paper_lantern
CPANEL_DEFAULT_DOMAIN_DIR=public_html
CPANEL_TOKEN=xxxxx
CPANEL_DOMAIN=example.com

Usage

Domains

Create domain

$domain = 'example.com';

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

Delete domain

$domain = 'example.com';

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

Addon domains

Create addon domain

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

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

Delete addon domain

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

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

Subdomain

Create 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);

Delete subdomain

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

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

Database

Create database

$db_name = 'fresh_database';

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

Delete database

$db_name = 'my_old_database';

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

Database User

Create database user

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

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

Add user to database

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

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

Delete database user

    $db_user = 'my_old_user_name';

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

License

CPanel package is open-sourced software licensed under the MIT license.