• Stars
    star
    106
  • Rank 325,871 (Top 7 %)
  • Language
    PHP
  • Created over 13 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

cPanel PublicAPI PHP client and cPanel PHP library

cPanel PublicAPI PHP Repository

This is the repository for the cPanel PublicAPI client written in PHP.

What's Included

The repository contains the following items. Each of which is explained in further detail below:

  • The cPanel PHP library
  • The PublicAPI client class
  • An examples directory
  • The PHPUnit tests for the cPanel PHP library and PublicAPI client class

QuickStart Example of the PublicAPI Client

This quick start example illustrates:

  1. Instantiating the PublicAPI client object with a configuration array.
  2. Invoking the whm_api() method for querying the XML-API::version function
  3. Getting the version string from the response object

Code: <?php

    // Include the autoloader
    require_once realpath( dirname(__FILE__) . '/Util/Autoload.php');
    
    // Make a configuration data array
    $config = array(
        'service' => array(
            'whm' => array(
                'config'    => array(
                    'host' => '10.1.4.191',
                    'user' => 'root',
                    'password' => 'rootsecret'
                ),
            ),
        ),
    );
    
    // Instantiate the PublicAPI client
    $cp = Cpanel_PublicAPI::getInstance($config);
    
    // Make a Whostmgr query
    $response = $cp->whm_api('version');
    
    // Print result string
    echo "WHM Version: {$response->version}\n";
    
?>

The cPanel PHP Library

The cPanel PHP library is a foundation for developers to build applications and scripts that interact with cPanel systems.

Version 0.1.0 is compatible with PHP >= 5.2

The library is divided into components. The follow list itemizes a few of the components, and their description, that are in the library:

  • Cpanel_Query

    Abstract classes for creating objects that can query a cPanel system

  • Cpanel_Service

    Concrete and abstract classes that represent cPanel Services like Whostmgr and cPanel

  • Cpanel_Parser

    Classes that allow for encoding and decoding common string and data structures

  • Cpanel_Util

    Utility files and scripts for developing with the cPanel library

  • ... and others

The PublicAPI Client Class

PublicAPI is the moniker for cPanel's defined, client interface: A contract if you will, that presents a language agnostic set of methods for interacting with cPanel systems.

The PublicAPI PHP client class in this repository is a PHP implementation of that interface. The client supports all methods of the PublicAPI interface as well as most of the methods available in previous PHP client classes, such as the XML-API client class.

Examples of how to code with the PublicAPI client class can be found:

  • In brief: The QuickStart Example of the PublicAPI Client section of this document
  • In detail: The examples directory, Cpanel/Examples/ within the repository

Version 0.1.0 is compatible with PHP >= 5.2

Examples Directory

There are several example files located in Cpanel/Examples/. Reading Introduction_to_PublicAPI.php is a good place to start. All other examples assume that you have read it.

Each example file is a working example if you substitute your own credentials and host information.

In fact, you can even run the LivePHP example, Using_the_LivePHP_Service.php, locally without having to download and install it respective of the LivePHP environment. This is possible due to a mock server that is part of the testing apparatus. Note: this is a very, very simple mock server and is not intended for anything other than example usage. So please, do not implement or rely on it.

Unit Tests

Unit tests for the cPanel PHP library and the PublicAPI client class are included in the Cpanel/Tests/ directory. They are written for use with PHPUnit >= 3.5 These test will require PHP 5.3 or greater, as they use specific Reflection functions that allow for assertions to be made on properties and methods whose visibility is private or protected.

More Repositories

1

xmlapi-php

A PHP Class for Interacting with cPanel's XML-API
PHP
229
star
2

cpanel-dynamicdns-tools

Shell
42
star
3

tech-CSI

cPanel Security Scan
YARA
41
star
4

tech-SysSnapv2

Perl
31
star
5

cPanel-PublicAPI

A perl module for interfacing with cPanel's various APIs
Perl
25
star
6

tech-MSP

Perl
17
star
7

backup-transport-dropbox

cPanel Custom Backup Transport for Dropbox
Perl
15
star
8

Custom-cPanel-Module

Example Perl module for extending the cPanel API
Perl
15
star
9

tech-acctinfo

Perl
14
star
10

cPMigration

Shell
13
star
11

tech-TechScripts

A Repository for Miscellaneous Scripts
Perl
11
star
12

tech-SysSnap

System Snapshot Utility
Shell
11
star
13

Paper_Lantern_Customizations

CSS
11
star
14

migrate-email

A cPanel Plugin for migrating email from an IMAP service
Perl
9
star
15

standard_hooks_examples

This page contains examples of how to implement Standard Hooks.
Perl
9
star
16

CpanelApiCallTracer

A utility that dumps the output from cPanel's API1 and API2 to the error_log
9
star
17

cpanel-node-api

A javascript library to abstract calling several of the cPanel & WHM API using a simplified object model. This library just build the syntax. You need to supply the HTTP request/response processes.
TypeScript
9
star
18

yum-plugin-universal-hooks

Python
7
star
19

tech-ESP

ESP - Enhanced Shell Prompt
Shell
7
star
20

ea-php74

Shell
7
star
21

tech-cp_license_troubleshooter

Perl
6
star
22

cplocales

Locales for cPanel & WHM
6
star
23

ea-nginx

EXPERIMENTAL
Perl
6
star
24

scl-phalcon

PHP Phalcon for EA4
Perl
5
star
25

ea-apache2

Shell
5
star
26

ea-apache2-config

Perl
5
star
27

ea-cpanel-tools

Perl
4
star
28

cPanel-PreInstall-Check

Shell
4
star
29

ea-php80

Shell
3
star
30

tech-AutoSSH

Perl
3
star
31

EA4-experimental

Makefile
3
star
32

ea4-example-specs

3
star
33

tech-dns-tools

Perl
3
star
34

cpanelinc.github.com

cPanel on GitHub
3
star
35

ea-documentroot

HTML
2
star
36

wpt-misc

Various tools and utilities for WordPress Toolkit
Shell
2
star
37

sandboxify

Shell
2
star
38

scl-ruby24-rubygem-mizuho

Perl
2
star
39

ea-nodejs10

nodejs 10 (EOL) for EA4
Perl
2
star
40

controllerify

Shell
2
star
41

ea-tomcat85

Tomcat 8.5 (EOL) for EA4
Perl
2
star
42

siteocity_customizations

CSS
2
star
43

php-cli

Perl
2
star
44

tech-WebStatsProbe

A simple tool for checking webstats configuration on cPanel servers
Perl
2
star
45

ea-modsec2-rules-owasp-crs

Shell
2
star
46

scl-sourceguardian

Perl
2
star
47

libcurl

EasyApache 4 repository for libcurl
Perl
2
star
48

ea-libc-client

Essentially a `BuildRequires` only pkg
Makefile
2
star
49

comment-handler

a cron-able, pluggable system to disable alerts for systems with open cases against them
Perl
2
star
50

PostMig

Post migration check project
Perl
1
star
51

zonegrep

find relevant information in a BIND zone file
Perl
1
star
52

ea-oniguruma

Perl
1
star
53

mod_fcgid

EXPERIMENTAL
Perl
1
star
54

automaat

Scripts to help automate Maatkit replication tools
Perl
1
star
55

ea-php71-php-memcached

Makefile
1
star
56

scl-autotools-latest-meta

Makefile
1
star
57

mod_security2

Perl
1
star
58

scl-php-pear

Perl
1
star
59

scl-ioncube10

Makefile
1
star
60

ea-nginx-standalone

EXPERIMENTAL
Makefile
1
star
61

ea-profiles-cpanel

Shell
1
star
62

scl-ioncube12

Perl
1
star
63

ea-php73-php-memcache

Shell
1
star
64

mod_suphp

Shell
1
star
65

ea-apache24-mod_evasive

Shell
1
star
66

ea-modsec30-connector-apache24

EXPERIMENTAL
Perl
1
star
67

scl-zendguard

Makefile
1
star
68

mod_bw

mod_bw for ea4
Shell
1
star
69

ea-openssl

Perl
1
star
70

ea4-contrib

Makefile
1
star
71

ea-php74-php-memcache

Shell
1
star
72

ea-php74-php-memcached

Shell
1
star
73

ea-ruby27

ruby 2.7 (EOL) for EA4
Ruby
1
star
74

pear

cPanel's PEAR channel
1
star
75

ea-freetds

FreeTDS RPM for EA4
Perl
1
star
76

MX-Routing-Checker

Utility script for detecting what MX routing logic will be used by cPanel for a given domain.
1
star
77

ea-openssl11

Perl
1
star
78

ch-server

Perl
1
star
79

stage-manager

simple staging to production webapp
Perl
1
star
80

scl-autotools-latest-autoconf

Makefile
1
star
81

EA4-legacy

Makefile
1
star
82

pupdate

automated updater of Puppet agent to Puppet 7
Perl
1
star
83

ea-php74-meta

Shell
1
star
84

ea-php80-meta

Shell
1
star
85

p5-Unicode-ICU

CPAN’s Unicode::ICU
Perl
1
star
86

ea-podman

Perl
1
star
87

hiera5-postgres-backend

Puppet code for a Hiera5 backend in a Postgres database
Ruby
1
star
88

ea-apache24-mod_cpanel

apache24-mod_cpanel (EOL) for EA4
C
1
star
89

ea-modsec30-connector-nginx

EXPERIMENTAL
Perl
1
star
90

ea-libzip

Perl
1
star
91

ea-php72-php-memcached

Makefile
1
star
92

tech-vm_setup

script to make changes to the meteorologist vms
Perl
1
star
93

diff-tools

Diff Enhancement Tools for Git
Perl
1
star
94

scl-ruby24-rubygem-sqlite3

Perl
1
star
95

ea-php80-php-memcached

EXPERIMENTAL
Shell
1
star
96

scl-php56

Shell
1
star
97

scl-autotools-latest-m4

Standard ML
1
star
98

tech-accounting_cruft_probe

script to check for remnants of a deleted account on a cPanel server
Perl
1
star
99

ea-nghttp2

Perl
1
star
100

beats-puppet-module

install and configure Elastic's filebeat and metricbeat using Puppet
Puppet
1
star