Skip to content

Commit

Permalink
first version after migration from fintech-systems/whmcs-php-api
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenefvdm committed Oct 19, 2024
1 parent e0844ca commit ee839ae
Show file tree
Hide file tree
Showing 18 changed files with 5,212 additions and 3,413 deletions.
15 changes: 11 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
WHMCS_URL=http://localhost/
WHMCS_URL=https://whmcs.test
WHMCS_API_IDENTIFIER=123
WHMCS_API_SECRET=456

WHMCS_URL2=http://localhost/
WHMCS_API_IDENTIFIER2=789
WHMCS_API_SECRET2=101112
# Enable to output debugging information
WHMCS_DEBUG=false

# The number of API results to return per call
WHMCS_LIMITNUM=100

# Optional. Only used if you need to connect to two different WHMCS servers.
#WHMCS_URL2=https://whmcs2.test
#WHMCS_API_IDENTIFIER2=789
#WHMCS_API_SECRET2=101112
1 change: 1 addition & 0 deletions .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"pest_3.4.0","defects":{"P\\Tests\\ApiTest::__pest_evaluable_it_can_access_a_test_whmcs_installation":1,"P\\Tests\\ApiTest::__pest_evaluable_it_can_connect_to_a_secondary_WHMCS_instance_using_a_Laravel_facade_and_retrieve_a_client_s_details":1,"P\\Tests\\ApiTest::__pest_evaluable_it_can_place_a_new_order":7},"times":{"P\\Tests\\ApiTest::__pest_evaluable_php_pest_is_installed_and_operational":0.042,"P\\Tests\\ApiTest::__pest_evaluable_it_can_access_a_test_whmcs_installation":0,"P\\Tests\\ApiTest::__pest_evaluable_adding_a_new_user_to_WHMCS_doesn_t_return_an_invalid_IP_error":0.076,"P\\Tests\\ApiTest::__pest_evaluable_it_will_add_an_USA_user_with_telephone_number_and_dashes_to_the_system_for_later_testing":0.013,"P\\Tests\\ApiTest::__pest_evaluable_it_can_add_a_user_to_the_billing_system":0.011,"P\\Tests\\ApiTest::__pest_evaluable_it_can_find_a_South_African_user_by_telephone_number_in_the_billing_system":0.011,"P\\Tests\\ApiTest::__pest_evaluable_it_can_find_a_South_African_user_by_telephone_number_without_spaces_in_the_billing_system":0.015,"P\\Tests\\ApiTest::__pest_evaluable_it_can_find_a_South_African_user_by_telephone_with_spaces_in_the_billing_system":0.009,"P\\Tests\\ApiTest::__pest_evaluable_it_can_find_a_USA_user_by_telephone_number_in_the_billing_system":0.017,"P\\Tests\\ApiTest::__pest_evaluable_it_can_connect_to_a_WHMCS_instance_using_the_Laravel_facade_and_pull_a_clients_details":0.012,"P\\Tests\\ApiTest::__pest_evaluable_it_can_connect_to_a_secondary_WHMCS_instance_using_a_Laravel_facade_and_retrieve_a_client_s_details":0.003,"P\\Tests\\ApiTest::__pest_evaluable_it_can_retrieve_at_least_two_domains":0.014,"P\\Tests\\ApiTest::__pest_evaluable_it_retrieve_registrars":0.015,"P\\Tests\\ApiTest::__pest_evaluable_it_can_use_a_modified_UpdateClientAddon_API_action_to_inject_new_API_actions":0.01,"P\\Tests\\ApiTest::__pest_evaluable_it_can_call_a_custom_API_action_called__setRegistrarSettingValue_":0.015,"P\\Tests\\ApiTest::__pest_evaluable_it_can_update_a_client_s_domain_registrar":0.013,"P\\Tests\\ApiTest::__pest_evaluable_it_can_place_a_new_order":0.006}}
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Changelog

All notable changes to `whmcs-php-api` will be documented in this file.
All notable changes to `whmcs-api` will be documented in this file.

## 19 Oct 2024

- Moved the repo from `fintech-systems/whmcs-php-api` to `eugenefvdm/whmcs-api`
- Updated the README to specify that URLs should not have a trailing slash
- Upgraded Pest so that we can use `->todo()`
- Changed the WHMCS test installation test from `->skip()` to `->todo()`
- Took out the section `Why` in the readme
- Upgraded these composer libraries: `pest`, `orchestra test bench`, `dotenv`, `spatie-ray`
- Bumped the PHP version to `8.2`
- Followed various PhpStorm IDE suggestions to improve the code
- Added a new environment setting `WHMCS_DEBUG`
- Created an automated test for adding new orders

## Unreleased

Expand Down
38 changes: 31 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# WHMCS API
![GitHub release (latest by date)](https://img.shields.io/github/v/release/fintech-systems/whmcs-php-api) ![Tests](https://github.com/fintech-systems/whmcs-php-api/actions/workflows/tests.yml/badge.svg) ![GitHub](https://img.shields.io/github/license/fintech-systems/whmcs-php-api)

A WHMCS API designed to run standalone or as part of a Laravel Application
A fully testable WHMCS API designed to run standalone or as part of a Laravel Application

Requirements:

- PHP 8.1
- WHMCS

# Why this package?
# Installation

WHMCS already has an extensive API. Why build another API? The reason is quite simple:
In WHMCS, create API permissions at:

The WHMCS API code examples depend on CURL. Mocking CURL is possible but complicated. Instead, Laravel already has beautiful HTTP testing and Http::fake mocking. Using Laravel (and in this case, Pest) means application development is sped up tremendously. Essentially you get away from testing against development servers. Even if you're not using Laravel, the framework's testing ability means it's possibly to write more complex software that's fail safe.

# Usage
```
System Settings => API credentials => Generate New API Credential
```

## WHMCS API Permissions

Expand Down Expand Up @@ -85,7 +85,7 @@ If you haven't added the PHP file yet, you'll get `API Function Not Found`
```php
<?php

use FintechSystems\WhmcsApi\WhmcsApi;
use Eugenefvdm\WhmcsApi\WhmcsApi;

require 'vendor/autoload.php';

Expand Down Expand Up @@ -166,6 +166,30 @@ A new package is applied to the service. If the package is linked to an API, the

# Testing

Before testing, please ensure you have at least the following three environment variables set:

```dotenv
WHMCS_URL=
WHMCS_API_IDENTIFIER=
WHMCS_API_SECRET=
```

Note: `WHMCS_URL` should be without the trialing slash otherwise tests will fail. For example:

```dotenv
WHMCS_URL=https://whmcs.test
```

You may do this:

`cp .env.example .env`

Then edit `.env` to include your WHMCS URL, API Identifier and API Secret.

`vi .env`

## Running the tests

`./vendor/bin/pest`

If you want to run individual tests, append `->only();` to each test.
Expand Down
26 changes: 12 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
{
"name": "fintech-systems/whmcs-php-api",
"description": "A PHP API to interface with WHMCS",
"name": "eugenefvdm/whmcs-api",
"description": "A testable PHP/Laravel API for WHMCS",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"FintechSystems\\Whmcs\\": "src/"
"Eugenefvdm\\Whmcs\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"FintechSystems\\Whmcs\\Tests\\": "tests"
"Eugenefvdm\\Whmcs\\Tests\\": "tests"
}
},
"authors": [
{
"name": "Eugene van der Merwe",
"email": "eugenevdm@gmail.com"
"email": "hello@eugenefvdm.com"
}
],
"require": {
"php": "^8.1",
"symfony/dotenv": "^5.3",
"spatie/ray": "^1.30",
"guzzlehttp/guzzle": "^7.5"
"php": "^8.2",
"spatie/ray": "^1.41",
"symfony/dotenv": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"orchestra/testbench": "^6.20",
"pestphp/pest": "^1.20"
"pestphp/pest": "^3.4",
"orchestra/testbench": "^9.5"
},
"extra": {
"laravel": {
"providers": [
"FintechSystems\\Whmcs\\WhmcsServiceProvider"
"Eugenefvdm\\Whmcs\\WhmcsServiceProvider"
]
},
"aliases": {
"Whmcs": "FintechSystems\\Whmcs\\Facades\\Whmcs"
"Whmcs": "Eugenefvdm\\Whmcs\\Facades\\Whmcs"
}
},
"config": {
Expand Down
Loading

0 comments on commit ee839ae

Please sign in to comment.