Skip to content
A PHP API Wrapper for the default WHMCS API commands
PHP
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE
src
tests
.gitignore
.mergify.yml
.travis.yml
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
README.md
SECURITY.md
composer.json

README.md

WHMCSAPI - The WHMCS, PHP API Wrapper

Build Status Mergify Status

This project is simple. It is an object-oriented library of the WHMCS API functions. To use this wrapper is simple.

Requirements

  • PHP 7.3 (It may work on lower. I only test on PHP 7.3 due to dev-dependencies)
  • Composer
  • WHMCS Installation (and License!) - Buy Here

Usage

First, import the library. As WHMCSAPI is currently in alpha/beta status, set the minimum version to 1.0@alpha:

composer require PeteBishwhip/WHMCSAPI:"^1.0@alpha"

After you have imported the library, initialize the wrapper by providing three values.

Variable Description
$apiIdentifier Your API Identifier
$apiSecret Your API Secret
$whmcsUrl Your WHMCS URL (e.g. https://example.com/whmcs/)
use WHMCSAPI\WHMCSAPI;

// $whmcsApi = new WHMCSAPI('abc123', '123cba', 'https://example.com/whmcs/');
$whmcsApi = new WHMCSAPI($apiIdentifier, $apiSecret, $whmcsUrl);

After initializing the library, use command to set the API command you want to use:

try {
    $whmcsApi->command('AcceptOrder');
} catch (\WHMCSAPI\Exception\FunctionNotFound $e) {
    // Perform error handling here
    // You can retrieve the error with
    // $e->getMessage();
}

If the command is not available, a \WHMCSAPI\Exception\FunctionNotFound exception will be thrown to allow for catching errors. If you want to perform all actions in the same try/catch, catch WHMCSAPI\Exception\Exception. All exceptions extend from this.

From there, you can set any variables as documented in the WHMCS Developer Documentation:

$whmcsApi->orderid = 25;

When ready, you can finally execute the command:

$result = $whmcsApi->execute();

Contributing

Please see CONTRIBUTING.md for advice and guidance.

You can’t perform that action at this time.