承接 sburina/laravel-whmcs-up 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sburina/laravel-whmcs-up

Composer 安装命令:

composer require sburina/laravel-whmcs-up

包简介

WHMCS API client and user provider for Laravel

README 文档

README

Latest Stable Version Total Downloads License

WHMCS API client, user authentication provider, and SSO integration for Laravel.

Version Compatibility

Package Version PHP Laravel WHMCS SSO Method
2.x >= 8.2 10 - 13 8.1+ CreateSsoToken
1.x >= 7.2 5.5 - 9 5.x - 8.0 AutoAuth

Installation

Version 2.x (Laravel 10+)

composer require sburina/laravel-whmcs-up:^2.0

Version 1.x (Laravel 5.5 - 9)

composer require sburina/laravel-whmcs-up:^1.1

Publish Configuration

php artisan vendor:publish --provider="Sburina\Whmcs\WhmcsServiceProvider"

The package auto-discovers in Laravel 5.5+. No manual service provider registration needed.

Configuration

Set these environment variables in your .env file:

WHMCS_URL=https://your-whmcs-installation.com
WHMCS_AUTH_TYPE=api
WHMCS_API_ID=your-api-identifier
WHMCS_API_SECRET=your-api-secret

Optional Variables

# Access key to bypass WHMCS IP restrictions
WHMCS_API_ACCESS_KEY=

# Admin auth (deprecated by WHMCS — use API credentials instead)
# WHMCS_AUTH_TYPE=password
# WHMCS_ADMIN_USERNAME=admin
# WHMCS_ADMIN_PASSWORD=secret

# SSL verification (default: true; set to false for self-signed dev certs)
WHMCS_VERIFY_SSL=true

# Request timeout in seconds (default: 30, v2.x only)
WHMCS_TIMEOUT=30

# Session key for storing authenticated user data
WHMCS_SESSION_USER_KEY=whmcs_user

# AutoAuth key (v1.x only — AutoAuth was removed in WHMCS 8.1)
WHMCS_AUTOAUTH_KEY=

See config/whmcs.php for all options.

Usage

API Client

The package provides convenience methods with clean signatures:

// Get products
\Whmcs::sbGetProducts($pid, $gid, $module);

// Get clients
\Whmcs::sbGetClients($limitstart, $limitnum, $sorting, $search);
// v2.x also supports: $orderby, $status parameters

// Get client details (email or clientid required)
\Whmcs::sbGetClientsDetails($email, $clientid, $stats);

// Validate login credentials
\Whmcs::sbValidateLogin($email, $password);

Magic Calls

Any WHMCS API action can be called directly. The method name becomes the API action:

\Whmcs::GetClientsProducts([
    'clientid' => 18122013
]);

\Whmcs::GetInvoice([
    'invoiceid' => 100001
]);

\Whmcs::AddOrder([
    'clientid'   => 1,
    'paymentmethod' => 'paypal',
    'pid'        => [1],
    'domain'     => ['example.com'],
]);

This works with any action listed in the WHMCS API Index, including custom API functions in your WHMCS installation.

Without Facades

$whmcs = app('whmcs');
$whmcs->GetInvoice(['invoiceid' => 100001]);

Authentication

Authenticate Laravel users against your WHMCS user base. This is useful when your Laravel app has no local user database.

Setup

1. In config/auth.php, set the provider driver:

'providers' => [
    'users' => [
        'driver' => 'whmcs',
    ],
],

The whmcs auth driver is registered automatically by the package (v1.1+ and v2.x). No manual Auth::provider() registration needed.

2. Use Laravel's built-in auth as usual:

// Routes
Auth::routes();

// Check authentication
auth()->check();
auth()->guest();

// Get the authenticated WHMCS user
$user = auth()->user(); // Returns WhmcsUser instance
$user->email;
$user->firstname;
$user->lastname;
$user->userid;

On successful login, user data from WHMCS is cached in the session. Subsequent auth()->user() calls use the cached data for the duration of the session.

Single Sign-On (SSO)

Authenticated users in your Laravel app are not automatically logged into WHMCS. Use SSO to redirect them.

Version 2.x — CreateSsoToken (WHMCS 8.1+)

// Redirect to WHMCS client area (logged in)
return \Whmcs::redirectSso();

// Redirect to a specific WHMCS page
return \Whmcs::redirectSso('clientarea.php?action=invoices');

// Get just the SSO URL
$url = \Whmcs::getSsoUrl();
$url = \Whmcs::getSsoUrl('cart.php');

You can also call the underlying API directly:

$result = \Whmcs::createSsoToken(
    clientId: 123,
    destination: 'sso:custom_redirect',
    ssoRedirectPath: 'clientarea.php?action=products'
);

// $result['redirect_url'] contains the one-time login URL

See CreateSsoToken API Reference.

Version 1.x — AutoAuth (WHMCS 5.x - 8.0)

AutoAuth must be enabled in WHMCS. See WHMCS AutoAuth.

WHMCS_AUTOAUTH_KEY=your-autoauth-secret-key
// Redirect to WHMCS (logged in)
return \Whmcs::redirectAutoLogin();

// Redirect to a specific page
return \Whmcs::redirectAutoLogin('cart.php');

// Get just the URL
$url = \Whmcs::getAutoLoginUrl();

Migrating from v1.x to v2.x

Requirements

  • PHP 8.2+
  • Laravel 10, 11, 12, or 13
  • WHMCS 8.1+

Breaking Changes

SSO: Replace AutoAuth calls with CreateSsoToken:

// Before (v1.x)
return \Whmcs::redirectAutoLogin('cart.php');
$url = \Whmcs::getAutoLoginUrl();

// After (v2.x)
return \Whmcs::redirectSso('cart.php');
$url = \Whmcs::getSsoUrl();

The old methods still exist in v2.x but trigger deprecation notices and will be removed in v3.

Config: The default session_key changed from user to whmcs_user. If you rely on the default, either update your code or set WHMCS_SESSION_USER_KEY=user in your .env.

SSL: SSL verification is now enabled by default. If you were relying on the old behavior (verification disabled), set WHMCS_VERIFY_SSL=false.

Auth provider registration: If you previously registered the auth provider manually in AuthServiceProvider, you can remove that code — it's now handled automatically by the package.

New Features in v2.x

  • sbGetClients() supports $orderby and $status parameters (WHMCS 8.2+)
  • Configurable request timeout via WHMCS_TIMEOUT
  • Uses Laravel's HTTP client instead of raw Guzzle

Support

Please open an issue on GitHub

License

MIT License. See LICENSE.

sburina/laravel-whmcs-up 适用场景与选型建议

sburina/laravel-whmcs-up 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.29k 次下载、GitHub Stars 达 26, 最近一次更新时间为 2018 年 09 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 sburina/laravel-whmcs-up 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sburina/laravel-whmcs-up 我们能提供哪些服务?
定制开发 / 二次开发

基于 sburina/laravel-whmcs-up 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.29k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 27
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 26
  • Watchers: 8
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-18