presttec / laravel-whmcs
Laravel WHMCS API interface
Requires
- php: ^7.2.5|^8.0
- ext-json: *
- illuminate/events: ~6.0|~7.0|~8.0
- illuminate/session: ~6.0|~7.0|~8.0
- illuminate/support: ~6.0|~7.0|~8.0
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- guzzlehttp/guzzle: ^7.0
- http-interop/http-factory-guzzle: ^1.0
- mockery/mockery: ~1.3
- orchestra/testbench: 5.x
- phpunit/phpunit: ^8.5.8|^9.3.3
Suggests
- guzzlehttp/guzzle: A PSR-18 compatible HTTP Client (^7.0)
- http-interop/http-factory-guzzle: PSR-17 compatible HTTP Factories (^1.0)
Conflicts
Replaces
README
An interface for interaction with the WHMCS API in Laravel.
Installation
Install the package through Composer. Run the Composer require command from the Terminal:
composer require presttec/laravel-whmcs
Package will be installed automaticlly through composer package discovery. If not, then you need to register
the PrestTEC\Whmcs\WhmcsService
service provider in your config/app.php.
Optionally, you can add the alias if you prefer to use the Facade
'Whmcs' => PrestTEC\Whmcs\Facades\Whmcs::class
Configuration
To get started, you'll need to publish all vendor assets.
php artisan vendor:publish --provider=PrestTEC\Whmcs\WhmcsServiceProvider
Then open config\whmcs.php
to fill your WHMCS api credentials in
Now you can use the WHMCS API in your Laravel project.
Lumen
Copy the config file from the package to your projects config directory:
cp vendor/presttec/laravel-whmcs/config/whmcs.php config/whmcs.php
Then open config\whmcs.php
to fill your WHMCS api credentials in.
To finish this, register the config file and the service provider in bootstrap/app.php
:
$app->configure('whmcs'); $app->register(PrestTEC\Whmcs\WhmcsServiceProvider::class);
Now you can use the WHMCS API in your Lumen project.
Basic Usage
You can call your WHMCS API directly by calling the \WHMCS::{WHMCSAPIFUNCTION}
facade.
If you prefer dependency injection, you can inject the manager like this:
use PrestTEC\Whmcs\WhmcsManager; class WhmcsController extends Controller { private $whmcsManager; public function __construct(WhmcsManager $whmcsManager) { $this->whmcsManager = $whmcsManager; } public function index() { $this->whmcsManager->execute('GetInvoice', ['invoiceid' => '1337']); } }
Hint: The execute command will also support your self-created WHMCS api commands.
Examples
Obtain a list of client purchased products:
\Whmcs::GetClientsProducts([ 'clientid' => '12345' ]);
Retrieve a specific invoice:
\Whmcs::GetInvoice([ 'invoiceid' => '1337' ]);
Support
Please open an issue in github
License
This package is released under the MIT License. See the bundled LICENSE file for details.
Contributing to Laravel Whmcs
If you find a bug or want to add a feature to Laravel Whmcs, great! In order to make it easier and quicker for me to verify and merge changes in, it would be amazing if you could follow these few basic steps:
- Fork the project.
- Branch out into a new branch.
git checkout -b name_of_new_feature_or_bug
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don’t break it in a future version unintentionally.
- Commit.
- Send me a pull request!