How to Set Up a WHMCS Dev Environment for Safe Customization & Testing< Print

  • WHMCS, MySQL
  • 0

Setting up a WHMCS test environment ensures that you can verify customizations, updates, and module functionality without impacting your production system. This guide outlines best practices for creating a WHMCS test environment, including data duplication, configuration adjustments, and troubleshooting tips.

Pre-Requirements

  • Access to WHMCS production installation files and database.
  • A valid WHMCS development license (contact WHMCS Customer Service to obtain one).
  • A hosting environment with identical system requirements to your production installation.

Step-by-Step Guide to Creating a WHMCS Test Environment

1. Obtain a WHMCS Development License

Contact WHMCS Customer Service for a development license. Each active license purchased directly from WHMCS includes a free development license, while licenses from resellers require a separate purchase.

Gotcha:

Development installations must be private. Ensure unauthorized access is blocked using a login prompt or a Forbidden error.

2. Meet System Requirements

Ensure your test environment meets the same system requirements as your production installation to avoid compatibility issues during testing.

3. Duplicate WHMCS Installation Files

For consistency, copy the WHMCS files from your production environment to your test environment. If using cPanel:

  1. Log in to cPanel and navigate to Files > File Manager.
  2. Select the folder containing your WHMCS installation and click Copy.
  3. Specify the destination folder for your development environment.

Gotcha:

Edit the configuration.php file in your test environment to reflect the new directory paths and URLs.

4. Duplicate the WHMCS Database

Create a clone of your WHMCS database to preserve real client data in the test environment. If using cPanel:

  1. Create a new database in MySQL Databases.
  2. Export your production database using phpMyAdmin and import it into the new database.

5. Secure the Test Environment

Restrict access to the test environment to prevent unauthorized access:

  1. In cPanel, go to Files > Directory Privacy to password-protect the directory.

Gotcha:

Failure to secure the test environment may expose sensitive information or allow unintended access.

6. Update the System URL

Set the System URL to the new environment's URL in Configuration > System Settings > General Settings. Alternatively, you can update this directly in the database:

UPDATE `tblconfiguration` SET value='https://billing.example_domain.com/' WHERE setting='SystemURL';

7. Disable Email Sending

To avoid sending emails to real customers from your test environment:

  1. Go to Configuration > System Settings > General Settings and enable Disable Email Sending in the Mail tab.

Gotcha:

Consider using services like Mailtrap.io to capture test emails safely.

8. Prevent Accidental Charges

Set payment gateways and domain registrars to test mode and disconnect from live servers. Additionally, add characters to the encryption hash in configuration.php to prevent real transactions:

// Example encryption hash modification
$cc_encryption_hash = 'additional_characters_here';

Testing and Verifying WHMCS Updates

1. Test New Versions and Features

After duplicating the environment, proceed with the WHMCS update using the Automatic Updater for a streamlined experience. Verify all features post-update:

  • Place test orders for each product type and ensure the workflow completes as expected.
  • Review System Health and Cron Job Activity Report for potential issues.

2. Test Modules

Enable test modes in registrar and gateway modules, where applicable, to simulate transactions without affecting real data. Confirm reversibility of actions taken for easy system resets.

Gotcha:

For provisioning modules, verify you can reverse actions, such as deleting test cPanel accounts, to maintain a clean test environment.

3. Test Automation Settings

Review Billing > Gateway Log and Configuration > System Logs for accuracy in automated payments and domain registrar activities. Any automation issues will appear in the Module Debug Log.

Resetting Your WHMCS Test Environment

After testing, reset the test environment to remove data while preserving configuration settings:

TRUNCATE `mod_invoicedata`;
TRUNCATE `tblinvoicedata`;
TRUNCATE `tblaccounts`;
TRUNCATE `tblactivitylog`;
TRUNCATE `tblaffiliates`;
TRUNCATE `tblaffiliatesaccounts`;
TRUNCATE `tblaffiliateshistory`;
TRUNCATE `tblaffiliatespending`;
TRUNCATE `tblaffiliateswithdrawals`;
TRUNCATE `tblbankaccts`;
TRUNCATE `tblbillableitems`;
TRUNCATE `tblcancelrequests`;
TRUNCATE `tblclients`;
TRUNCATE `tblclientsfiles`;
TRUNCATE `tblcontacts`;
TRUNCATE `tblcredit`;
TRUNCATE `tblcreditcards`;
TRUNCATE `tblcustomfieldsvalues`;
TRUNCATE `tbldomains`;
TRUNCATE `tbldomainsadditionalfields`;
TRUNCATE `tblemails`;
TRUNCATE `tblhosting`;
TRUNCATE `tblhostingaddons`;
TRUNCATE `tblhostingconfigoptions`;
TRUNCATE `tblinvoiceitems`;
TRUNCATE `tblinvoices`;
TRUNCATE `tblmodulequeue`;
TRUNCATE `tblnotes`;
TRUNCATE `tblorders`;
TRUNCATE `tblpaymethods`;
TRUNCATE `tblquotes`;
TRUNCATE `tblquoteitems`;
TRUNCATE `tblsslorders`;
TRUNCATE `tblticketlog`;
TRUNCATE `tblticketnotes`;
TRUNCATE `tblticketreplies`;
TRUNCATE `tbltickets`;
TRUNCATE `tbltodolist`;
TRUNCATE `tbltransaction_history`;
TRUNCATE `tblupgrades`;
TRUNCATE `tblusers`;
TRUNCATE `tblusers_clients`;
TRUNCATE `tbluser_invites`;

Gotcha:

Resetting only removes test data without affecting configuration or product settings.

Updating Storage Settings

If switching between development and production environments, verify that storage settings align with the respective environment to prevent feature disruptions (e.g., email functionality).


Did this answer help?

« Back

Trusted by over 35,000 customers in over 200 countries