Download the PHP package fintech-systems/whmcs-php-api without Composer
On this page you can find all versions of the php package fintech-systems/whmcs-php-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fintech-systems/whmcs-php-api
More information about fintech-systems/whmcs-php-api
Files in fintech-systems/whmcs-php-api
Package whmcs-php-api
Short Description A testable PHP/Laravel API for WHMCS
License MIT
Informations about the package whmcs-php-api
WHMCS API
A testable WHMCS API designed to run standalone or as part of a Laravel Application
Requirements:
- PHP 8.2
- WHMCS
Installation
Publish the configuration file:
Configuration Settings whmcs.php
WHMCS_URL
should be without the trialing slash.
WHMCS Setup
Allow the IP address of the system connecting to WHMCS:
Create API permissions:
Example API permissions required:
- addclient
- getclientsdetails
- getclientsdomains
- custom list of API calls you are developing
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.
- Create a custom API call
- 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
Publish the configuration file:
php artisan vendor:publish --tag=whmcs-config
Changelog
See CHANGELOG for more information on what has changed recently.
Features
Set Server
Provides the ability to connect to a secondary WHMCS server away from the Facade initiation
Change Package
Change Package
Framework Agnostic PHP:
Laravel App:
Change server
Since we're using a Facade instantiated when it's called, we need some other way to call the constructor when we're connecting to another server.
Result:
A new package is applied to the service. If the package is linked to an API, the API will be called.
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. This will output to Spatie Ray if it's 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.