i4e/whmcs-laravel

Laravel WHMCS API interface

dev-main 2022-01-10 20:40 UTC

This package is auto-updated.

Last update: 2024-04-11 01:51:57 UTC


README

An interface for interaction with the WHMCS API in Laravel.

Installation

Install the package through Composer. Run the Composer require command from the Terminal:

composer require i4e/laravel-whmcs

Package will be installed automaticlly through composer package discovery. If not, then you need to register the i4e\Whmcs\WhmcsService service provider in your config/app.php.

Optionally, you can add the alias if you prefer to use the Facade

'Whmcs' => i4e\Whmcs\Facades\Whmcs::class

Configuration

To get started, you'll need to publish all vendor assets.

php artisan vendor:publish --provider=i4e\Whmcs\WhmcsServiceProvider

Then open config\whmcs.php to fill your WHMCS api credentials in

Now you can use the WHMCS API in your Laravel project.

Lumen

Copy the config file from the package to your projects config directory:

cp vendor/i4e/laravel-whmcs/config/whmcs.php config/whmcs.php

Then open config\whmcs.php to fill your WHMCS api credentials in.

To finish this, register the config file and the service provider in bootstrap/app.php:

$app->configure('whmcs');
$app->register(i4e\Whmcs\WhmcsServiceProvider::class);

Now you can use the WHMCS API in your Lumen project.

Basic Usage

You can call your WHMCS API directly by calling the \WHMCS::{WHMCSAPIFUNCTION} facade.

If you prefer dependency injection, you can inject the manager like this:

use i4e\Whmcs\WhmcsManager;

class WhmcsController extends Controller
{
    private $whmcsManager;

    public function __construct(WhmcsManager $whmcsManager)
    {
        $this->whmcsManager = $whmcsManager;
    }

    public function index()
    {
        $this->whmcsManager->execute('GetInvoice', ['invoiceid' => '1337']);
    }
}

Hint: The execute command will also support your self-created WHMCS api commands.

Examples

Obtain a list of client purchased products:

\Whmcs::GetClientsProducts([
    'clientid' => '12345'
]);

Retrieve a specific invoice:

\Whmcs::GetInvoice([
    'invoiceid' => '1337'
]);