jobsfav / laravel-whmcs
WHMCS API接口,适用于Laravel 7.0及以上版本
1.2.0
2023-02-02 00:15 UTC
Requires
- php: ^7.4|^8.0
- ext-json: *
- darthsoup/php-whmcs-api: ~1.3
- graham-campbell/manager: ^4.7
- illuminate/events: ^7.0|^8.0|^9.0|^10.0
- illuminate/session: ^7.0|^8.0|^9.0|^10.0
- illuminate/support: ^7.0|^8.0|^9.0|^10.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)
README
这是一个用于与Laravel中的WHMCS API交互的接口。本包深受由Graham Campbell创建的Laravel GitLab启发。
注意
旧版本0.3可以在这里找到
安装
WHMCS API for Laravel需要PHP ^7.4 | ^8.0,至少需要Laravel版本6。
通过Composer安装包。从终端运行Composer require命令
composer require darthsoup/laravel-whmcs
包将通过composer包发现自动安装。如果没有,那么您需要在您的config/app.php
中注册DarthSoup\Whmcs\WhmcsService
服务提供者。
可选,如果您喜欢使用Facade,可以添加别名
'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); } }
通过Facade
如果您更喜欢经典的Laravel facade样式,这可能是一种选择
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文件。