fafan/cpanel-php

Cpanel/WHM API for PHP

0.1.0 2016-10-10 03:30 UTC

This package is not auto-updated.

Last update: 2025-07-06 00:39:07 UTC


README

Code Climate Test Coverage Issue Count

CPanel/WHM API for PHP library

NOTE: This library is modified from original code of gufy/cpanel-php

I rewrite runQuery() function to use cURL instead of GuzzleHttp

Contents

Installation

To install this package, you can run this code via your terminal

	composer require fafan/cpanel-php

Or update your composer.json by adding this line

	"fafan/cpanel-php":"^0.1"

Then, run this code

	composer update

Usage

For example, if you would like to get list accounts of your whm server, you can do this.

  <?php
  $cpanel = new \Fafan\CpanelPhp\Cpanel([
      'host'        =>  'https://123.456.789.123:2087', // ip or domain complete with its protocol and port
      'username'    =>  'root', // username of your server, it usually root.
      'auth_type'   =>  'hash', // set 'hash' or 'password'
      'password'    =>  'password', // long hash or your user's password
  ]);

  $accounts = $cpanel->listaccts(); // it will returned as array

Functions

This is the example when you want to define your configuration while creating new object

  <?php
  $cpanel = new \Fafan\CpanelPhp\Cpanel([
      'host'        =>  'https://123.456.789.123:2087', // required
      'username'    =>  'root', // required
      'auth_type'   =>  'hash', // optional, default 'hash'
      'password'    =>  'password', // required
  ]);

Somehow, you want to override your current configuration. To do this, here is the code

  <?php
  // change username andd (password or hash)
  $cpanel->setAuthorization($username, $password);

  // change host
  $cpanel->setHost($host);

  // change authentication type
  $cpanel->setAuthType($auth_type);

Get defined configuration

After you define some of your configuration, you can get it again by calling this functions

  <?php
  // get username
  $cpanel->getUsername();

  // get password
  $cpanel->getPassword();

  // get authentication type
  $cpanel->getAuthType();

  // get host
  $cpanel->getHost();

Credits

Original code: gufy/cpanel-php, version 1.0

By Mochamad Gufron mgufronefendi@gmail.com