Download the PHP package eugenefvdm/whmcs-api without Composer

On this page you can find all versions of the php package eugenefvdm/whmcs-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package whmcs-api

WHMCS API

GitHub release (latest by date) Tests GitHub Downloads

A testable WHMCS API designed to run standalone or as part of a Laravel application.

Requirements:

Installation

Publish the configuration file:

Configuration Settings whmcs.php

WHMCS_URL should be without the trailing slash.

For local installs without a valid TLS certificate (e.g. https://whmcs.test), set WHMCS_VERIFY_SSL=false.

WHMCS_DEFAULT_REG_PERIOD is optional; used by addDomainRegistrationOrder() when no period is passed.

WHMCS Setup

Allow the IP address of the system connecting to WHMCS:

Create API permissions:

Example API permissions required:

Example, creating a new client with custom fields:

Custom API calls

WHMCS removed the ability to add custom API calls, but there is a hack to get it working again.

An example of a custom API call would be to get a client by their phone number. Let's call this getclientbyphonenumber. At least two steps are required.

  1. Create a custom API call
  2. Inject the permission into the database

Example custom API call

Save the example code below here: includes/api/getclientbyphoneumber.php

Next to use the custom API call getclientbyphonenumber you need to manually update tblapi_roles and add it there.

Also remember to update it every time again you make a changes in the UI because the UI will overwrite the custom API call.

In the example below, the JSON in the database has been updated to include the new API call getclientbyphonenumber.

If you haven't added the PHP file yet, you'll get API Function Not Found.

Examples

Framework Agnostic PHP

Laravel

Use the Whmcs facade after publishing config:

Changelog

See CHANGELOG for more information on what has changed recently.

Features

Connecting to a WHMCS server

Prefer Whmcs::connect() for an isolated client instance — safe for per-tenant credentials or multiple servers in the same request:

setServer() mutates the current instance and is deprecated. The Laravel facade resolves a shared binding, so use connect() when switching servers.

Orders

List orders for a client:

ordersList() normalizes WHMCS's inconsistent single-item vs array responses via WhmcsResponse::list().

For Filament custom-data tables, use ordersPaginator() — returns a LengthAwarePaginator keyed by order id:

Place a domain registration order (wraps AddOrder):

Fetch order statuses for filter options:

Pagination defaults (limitstart, limitnum) are applied only on list endpoints such as getOrders() and getClients() — not on addOrder() or other write calls.

Change plan

Applies a new package to the service via ModuleChangePackage. If the package is linked to a provisioning module, WHMCS will call it.

Error handling

API errors throw WhmcsApiException with the WHMCS action name and parsed response:

Response normalization

WhmcsResponse helpers are available for any nested WHMCS collection:

Testing

Before testing, please ensure you have copied over the .env.example file to .env as the tests use dotenv.

Debugging

Set WHMCS_DEBUG=true in your .env file to enable debugging. When enabled, request and response payloads are sent to Spatie Ray if it is installed.

Running the tests

./vendor/bin/pest

To test custom API actions, use a script such as the following:

sh .scp updateclientaddon.php;./vendor/bin/pest

The .scp file should have a copy command, e.g.:

No errors on API actions but not working

API actions are difficult to troubleshoot if you don't observe the server log file. Only some exceptions, e.g., model problems will be caught by the Try Catch block. So help tail your server log file. For example, if you're using Laravel's Valet's Nginx server, do this:

tail -f ~/.valet/Log/nginx-error.log

Invalid IP 127.0.0.1

If you get Invalid IP 127.0.0.1 that means you haven't allowed WHMCS API access from localhost.

Navigate here: https://whmcs.test/admin/configgeneral.php and make sure you add 127.0.0.1 to API IP Access Restriction.

Invalid or missing credentials

If you get Invalid or missing credentials that means you haven't added API roles and API credentials. Both are required before you can test. Also be sure to add them to your .env file:

Invalid Permissions: API action "addclient" is not allowed

If you get Invalid Permissions: API action "addclient" is not allowed that means, although you've added API roles and credentials, your roles are not set up properly for the API call. Revisit roles and the requisite subsection and see where you have to click the checkbox to allow this API call.

Storage folder examples

The storage folder has examples API responses, also used for caching during tests.

Local Editing

For local editing, add this to composer.json:

Then in require section:

Then do this to symlink:

License

MIT

Author

hello (at) eugenefvdm.com
https://eugenefvdm.com
+27 82 309–6710
I am a Laravel, hosting, and WHMCS specialist. Contact me any time for assistance.


All versions of whmcs-api with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
spatie/ray Version ^1.41
symfony/dotenv Version ^7.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package eugenefvdm/whmcs-api contains the following files

Loading the files please wait ...