Skip to content

Stdubic/whmc-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WHMCS Module Demonstration

A complete boilerplate/template for building WHMCS provisioning modules. This project provides a working example with Docker-based local development environment.

Features

  • Complete Module Structure: Full provisioning module with all required functions
  • API Integration Template: Ready-to-use API helper class
  • Docker Development Environment: Local WHMCS testing setup
  • Hook Examples: Common WHMCS hooks implemented
  • Best Practices: Follows WHMCS module development guidelines

Requirements

  • WHMCS 8.0+
  • PHP 7.3+
  • Docker & Docker Compose (for local development)
  • cURL extension enabled

Quick Start

1. Install the WHMCS Module

Copy the module to your WHMCS installation:

cp -r whmcs/modules/servers/demo /path/to/whmcs/modules/servers/
cp -r whmcs/includes/hooks/* /path/to/whmcs/includes/hooks/

2. Configure Server in WHMCS

  1. Go to Setup → Products/Services → Servers
  2. Click Add New Server
  3. Configure:
    • Name: Demo Service
    • Hostname: Your API endpoint URL
    • Type: Demo Module
    • Password: Your API Key

3. Create a Product

  1. Go to Setup → Products/Services → Products/Services
  2. Create a new product with:
    • Module: Demo Module
    • Server Group: Your server group

4. Test the Integration

  1. Create a test order for a customer
  2. Accept the order and run Create from the service
  3. Verify the service shows "Active" status

Package Contents

whmc-modile/
├── whmcs/                    # WHMCS module files
│   ├── modules/servers/      # Provisioning module
│   │   └── demo/             # Demo module
│   └── includes/hooks/       # Hook examples
├── scripts/                  # Setup & utility scripts
├── tests/                    # Test files
└── docs/                     # Documentation

Local Development

Set up a local WHMCS environment with Docker:

# 1. Run the environment setup script
chmod +x scripts/setup-local.sh
./scripts/setup-local.sh

# 2. Start the Docker containers
docker compose up -d

# 3. Configure the module (creates server, product, test client)
chmod +x scripts/setup-module.sh
./scripts/setup-module.sh

Access URLs

Resource URL
WHMCS Client Area http://localhost:8088/
WHMCS Admin http://localhost:8088/admin/
phpMyAdmin http://localhost:8081/
MailHog http://localhost:8025/

Default Credentials

Service Username Password
WHMCS Admin admin password
MySQL whmcs password
MySQL Root root password

Module Functions

The demo module implements all standard WHMCS provisioning functions:

Function Description
CreateAccount Provision a new service
SuspendAccount Suspend a service
UnsuspendAccount Reactivate a suspended service
TerminateAccount Permanently remove a service
TestConnection Test API connectivity

Customization Guide

1. Rename the Module

Replace demo with your module name:

# Rename folder
mv whmcs/modules/servers/demo whmcs/modules/servers/yourmodule

# Update function prefixes in yourmodule.php
# Change: demo_MetaData, demo_CreateAccount, etc.
# To: yourmodule_MetaData, yourmodule_CreateAccount, etc.

2. Configure API Endpoints

Edit the ApiHelper class in your module:

$this->apiEndpoint = 'https://your-api.com/v1';

3. Add Custom Fields

Define product-specific options in ConfigOptions():

function yourmodule_ConfigOptions(): array
{
    return [
        'plan' => [
            'FriendlyName' => 'Plan Type',
            'Type' => 'dropdown',
            'Options' => ['basic' => 'Basic', 'pro' => 'Pro'],
        ],
    ];
}

Documentation

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

License

MIT License - feel free to use this as a starting point for your own modules.

Support

For WHMCS documentation, visit: https://developers.whmcs.com/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors