https://github.com/zanysoft/cpanel-api
Cpanel api
https://github.com/zanysoft/cpanel-api
api cpanel cpanel-api rest-api whm whm-api
Last synced: 5 months ago
JSON representation
Cpanel api
- Host: GitHub
- URL: https://github.com/zanysoft/cpanel-api
- Owner: zanysoft
- License: gpl-3.0
- Created: 2017-05-26T12:34:38.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2025-02-18T12:41:47.000Z (about 1 year ago)
- Last Synced: 2025-03-30T15:08:44.236Z (about 1 year ago)
- Topics: api, cpanel, cpanel-api, rest-api, whm, whm-api
- Language: PHP
- Homepage: https://zanysoft.github.io/cpanel-api/
- Size: 44.9 KB
- Stars: 27
- Watchers: 1
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cpanel's API
Cpanel's API 1 and 2 for Laravel
## Contents
- [Installation Guide](#installation-guide)
- [Configuration](#configuration)
- [Usage](#usage)
- [Functions](#functions)
- [Documentation](#documentation)
### Installation Guide
Require this package in your composer.json and update composer. This will download the package.
composer require zanysoft/cpanel-api
If using < Laravel 5.5, add the ServiceProvider and Aliases in config/app.php
'providers' => [
'...',
ZanySoft\Cpanel\CpanelServiceProvider::class,
];
'aliases' => [
'...',
'Cpanel' => ZanySoft\Cpanel\Facades\Cpanel::class,
];
### Configuration
The defaults configuration settings are set in `config/cpanel.php`. Copy this file to your own config directory to modify the values. You can publish the config using this command:
php artisan vendor:publish --provider="ZanySoft\Cpanel\CpanelServiceProvider"
### Usage
You can create a new Cpanel instance.
$cpanel = Cpanel::make();
$cpanel->setHost($host_ip);
$cpanel->setAuth($username, $password) //if you don't want to set in config file
return $cpanel->api2($user, $module, $function, $args = array());
Or use the facade:
return Cpanel::api2($user, $module, $function, $args = array());
You can use the facade with chain the methods:
return Cpanel::setHost($host_ip)->setAuth($username, $password)->api2($user, $module, $function, $args = array());
You can set the authentication before chain if you don't want to set this in config/cpanel.php file.
return Cpanel::setAuth($username, $password)->api2($user, $module, $function, $args = array());
You can set host, username and pasword on createing instance if you don't want to set this in config/cpanel.php file.
$cpanel = new \ZanySoft\Cpanel\Cpanel($host,$username, $password);
// OR
$cpanel = Cpanel::make($host,$username, $password);
### Functions
This is the example when you want to define your configuration
```php
setHost($host_ip);
$cpanel->setAuth($username, $password)
return $cpanel->api2($user, $module, $function, $args = array());
```
If you like to get some list accounts from cPanel/WHM
```php
listaccts();
// passing parameters
$accounts = $cpanel->listaccts($searchtype, $search);
```
If you want to create new subdomain
```php
createSubdomain('subdomain', 'username', '/public_html/subdomain', 'example.com')
```
For accessing cPanel API 2, you can use this.
```php
api2($user, $module, $function, $args = array());
```
For accessing cPanel API 1, you can use this.
```php
api1($user, $module, $function, $args = array());
```
### Documentation
Visit this link for api2 options: https://documentation.cpanel.net/display/SDK/Guide+to+cPanel+API+2
Visit this link for api1 options: https://documentation.cpanel.net/display/SDK/Guide+to+cPanel+API+1