darthsoup / php-whmcs-api
WHMCS API client for PHP
Installs: 7 799
Dependents: 4
Suggesters: 0
Security: 0
Stars: 20
Watchers: 5
Forks: 9
Open Issues: 0
Requires
- php: ^7.4|^8.0.2
- ext-json: *
- php-http/client-common: ^2.6
- php-http/discovery: ^1.17
- php-http/httplug: ^2.4
- psr/http-client-implementation: ^1.0
- psr/http-factory-implementation: ^1.0
- psr/http-message: ^1.1 || ^2.0
- symfony/options-resolver: ^5.0 || ^6.0 || ^7.0
Requires (Dev)
- guzzlehttp/guzzle: ^7.8
- http-interop/http-factory-guzzle: ^1.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^8.5.14 || ^9.5.1
README
Simple and PSR7 compatible WHMCS API Client which is inspired by GitLabPHP/Client.
Installation
Composer
$ composer require "darthsoup/php-whmcs-api" "guzzlehttp/guzzle:^7.5" "http-interop/http-factory-guzzle:^1.2"
System Requirements
This package requires:
- PHP ^7.4 | ^8.0
- PHP extensions
curl
,json
andmbstring
Usage
Initialize Client
Basic initialisation of the Client.
<?php require_once __DIR__ . '/vendor/autoload.php'; $client = new \DarthSoup\WhmcsApi\Client(); // Auth Credentials with identifier and secret $client->authenticate('your_identifier', 'your_secret', \DarthSoup\WhmcsApi\Client::AUTH_API_CREDENTIALS); // Login Credentials with Username and Password (without md5) $client->authenticate('your_username', 'your_password', \DarthSoup\WhmcsApi\Client::AUTH_LOGIN_CREDENTIALS); // Set the URL to your whmcs instance $client->url('http://<your_whmcs_instance_url>');
API access key
In case your instance has an additional $api_access_key
configured in your whmcs configuration.php
,
you can also add it by using accessKey
in the init process.
$client->accessKey('my_access_key');
Endpoints
Examples
Get clients
$client->client()->getClients(['search' => 'firstname']);
Get all orders
$client->orders()->getOrders();
Call custom API Route
If your WHMCS instance contains custom API routes, you can also call them without extending the code.
$parameters = ['foo' => 'bar']; $client->custom()->yourCustomApiName($parameters);
Examples by files
There are some examples in the /examples
folder if reading documentation is not your cup of tea.
Disclaimer
If you are using this client, please refer to the documentation on the WHMCS Developer page. The API documentation is in some places very incomplete and in some cases questionably documented.
Support
Please open an issue in github
License
This package is released under the MIT License. See the bundled LICENSE file for details.