darthsoup / laravel-whmcs
WHMCS API接口,适用于Laravel 7.0及以上版本
Requires
- php: ^7.4|^8.0
- ext-json: *
- darthsoup/php-whmcs-api: ~1.3
- graham-campbell/manager: ^5.1
- illuminate/events: ^8.0|^9.0|^10.0|^11.0
- illuminate/session: ^8.0|^9.0|^10.0|^11.0
- illuminate/support: ^8.0|^9.0|^10.0|^11.0
Requires (Dev)
- guzzlehttp/guzzle: ^7.0
- http-interop/http-factory-guzzle: ^1.0
- mockery/mockery: ~1.3
- nunomaduro/larastan: ^1.0.4
- orchestra/testbench: ^5.0|^6.0|^7.0|^8.0
- phpunit/phpunit: ^9.3
Suggests
- guzzlehttp/guzzle: A PSR-18 compatible HTTP Client (^7.0)
- dev-main
- 1.3.0.x-dev
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.0
- 1.0.0-beta.1
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.6
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1
- dev-dependabot/composer/nunomaduro/larastan-tw-2.9.8
- dev-dependabot/composer/phpunit/phpunit-tw-11.2
- dev-dependabot/composer/orchestra/testbench-tw-9.1.2
- dev-legacy
This package is auto-updated.
Last update: 2024-09-10 05:04:17 UTC
README
此包是用于在Laravel中与WHMCS API交互的接口。此包受到了Graham Campbell创建的Laravel GitLab的极大启发。
注意
旧版本0.3可以在这里找到
安装
WHMCS API for Laravel需要PHP ^7.4 | ^8.0,并且至少需要Laravel 8。
通过Composer安装该包。请在终端中运行Composer require命令
composer require darthsoup/laravel-whmcs
包将通过Composer包发现自动安装。如果没有,那么您需要在您的config/app.php
中注册DarthSoup\Whmcs\WhmcsService
服务提供者。
可选,如果您更喜欢使用外观,您可以添加别名
'Whmcs' => DarthSoup\Whmcs\Facades\Whmcs::class
配置
要开始使用,您需要发布Laravel-Whmcs的供应商资产。
php artisan vendor:publish --provider="DarthSoup\Whmcs\WhmcsServiceProvider"
这将创建应用中的config/whmcs.php
文件,您需要修改它以设置配置。
默认连接
选项default
是您指定默认连接的地方。
WHMCS连接
选项connections
是您可以添加多个连接到您的whmcs实例的地方。您可以从whmcs中选择两种API连接类型之一。这些方法包括password
和token
。已包含示例连接,但您可以添加您想要的任何数量的连接。
用法
通过依赖注入
如果您喜欢使用依赖注入,您可以很容易地将它添加到您的控制器中,如下所示
use DarthSoup\Whmcs\WhmcsManager; class WhmcsController extends Controller { private WhmcsManager $whmcsManager; public function __construct(WhmcsManager $whmcsManager) { $this->whmcsManager = $whmcsManager; } public function index() { $result = $this->whmcsManager->client()->getClients(); dd($result); } }
通过外观
如果您更喜欢传统的Laravel外观风格,这可能是一个不错的选择
use \DarthSoup\Whmcs\Facades\Whmcs; # or use \Whmcs; \Whmcs::Client()->getClientsDomains(['clientid' => '1']);
真实示例
use \DarthSoup\Whmcs\Facades\Whmcs; # Obtaining a list of domains purchased by the customer \Whmcs::Client()->getClientsDomains(['clientid' => '1']); # Obtaining a list of products purchased by the customer \Whmcs::Client()->getClientsProducts(['clientid' => '12345']); # Retrieve a specific invoice \Whmcs::Billing()->getInvoice(['invoiceid' => '1337']); # Retrieves all Orders from the system \Whmcs::Orders()->getOrders(); # Obtain internal users \Whmcs::Users()->getUsers(['search' => 'foo@bar.org']); # Custom Method (in case you added custom endpoints) \Whmcs::Custom()-><myEndpoint>(['foo' => 'bar']);
有关如何使用WhmcsApi客户端DarthSoup\WhmcsApi\Client
类的更多信息,请查看https://github.com/darthsoup/php-whmcs-api上的文档。
支持
许可证
此包根据MIT许可证发布。有关详细信息,请参阅附带LICENSE文件。