PHPackages                             shubuzuo-sdk/php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. shubuzuo-sdk/php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

shubuzuo-sdk/php
================

shubuzuo-php-sdk

00PHP

Since Mar 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/wedreamer/test-php-sdks)[ Packagist](https://packagist.org/packages/shubuzuo-sdk/php)[ RSS](/packages/shubuzuo-sdk-php/feed)WikiDiscussions main Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Authing - PHP
=============

[](#authing---php)

Authing PHP SDK 由两部分组成：`ManagementClient` 和 `AuthenticationClient`。`ManagementClient` 中进行的所有操作均以管理员的身份进行，包含管理用户、管理角色、管理权限策略、管理用户池配置等模块。`AuthenticationClient` 中的所有操作以当前终端用户的身份进行，包含登录、注册、修改用户资料、退出登录等方法。

你应该将初始化过后的 `ManagementClient` 实例设置为一个全局变量（只初始化一次），而 `AuthenticationClient` 应该每次请求初始化一个。

安装
--

[](#安装)

我们推荐使用 `composer` 进行安装， 它可以与一些模块打包工具很好地配合使用。

```
# latest stable
$ composer require authing-sdk/php
```

使用管理模块
------

[](#使用管理模块)

初始化 `ManagementClient` 需要 `userPoolId`（用户池 ID） 和 `secret`（用户池密钥）:

> 你可以在此[了解如何获取 UserPoolId 和 Secret](https://docs.authing.cn/v2/guides/faqs/get-userpool-id-and-secret.html) .

```
use Authing\Mgmt\ManagementClient;

$management = new ManagementClient("AUTHING_USERPOOL_ID", "AUTHING_USERPOOL_SECRET");
// 获取管理员权限
$management->requestToken();
```

现在 `managementClient` 实例就可以使用了。例如可以获取用户池中的用户列表：

```
use Authing\Mgmt\ManagementClient;

$management = new ManagementClient("AUTHING_USERPOOL_ID", "AUTHING_USERPOOL_SECRET");
// 获取管理员权限
$management->requestToken();
$users = $management->users()->paginate();
```

使用认证模块
------

[](#使用认证模块)

初始化 `AuthenticationClient` 需要 `userPoolId`（用户池 ID）：

> 你可以在此[了解如何获取 UserPoolId](https://docs.authing.cn/v2/guides/faqs/get-userpool-id-and-secret.html) .

```
use Authing\Auth\AuthenticationClient;

$authentication = new AuthenticationClient("AUTHING_USERPOOL_ID");
```

接下来可以进行注册登录等操作：

```
use Authing\Auth\AuthenticationClient;
use Authing\Types\LoginByEmailInput;

$authentication = new AuthenticationClient("AUTHING_USERPOOL_ID");
$user = $authentication->loginByEmail(new LoginByEmailInput("test@example.com", "123456"));
```

完成登录之后，`update_profile` 等要求用户登录的方法就可用了：

```
use Authing\Auth\AuthenticationClient;
use Authing\Types\LoginByEmailInput;
use Authing\Types\UpdateUserInput;

$authentication = new AuthenticationClient("AUTHING_USERPOOL_ID");
$authentication->loginByEmail(new LoginByEmailInput("test@example.com", "123456"));

$user = $authentication->updateProfile((new UpdateUserInput())->withNickname("nickname"));
```

你也可以在初始化后设置 `AccessToken` 参数, 不需要每次都调用 `LoginByXXX` 方法:

```
use Authing\Auth\AuthenticationClient;

$authentication = new AuthenticationClient("AUTHING_USERPOOL_ID");
$authentication->setAccessToken("ACCESS_TOKEN");
```

再次执行 `UpdateProfile` 方法，发现也成功了:

```
use Authing\Auth\AuthenticationClient;
use Authing\Types\UpdateUserInput;

$authentication = new AuthenticationClient("AUTHING_USERPOOL_ID");
$authentication->setAccessToken("ACCESS_TOKEN");

$user = $authentication->updateProfile((new UpdateUserInput())->withNickname("nickname"));
```

错误处理
----

[](#错误处理)

统一使用 try catch 处理：

```
use Authing\Auth\AuthenticationClient;
use Authing\Types\UpdateUserInput;

$authentication = new AuthenticationClient("AUTHING_USERPOOL_ID");
$authentication->setAccessToken("ACCESS_TOKEN");

try {
    $user = $authentication->updateProfile((new UpdateUserInput())->withNickname("nickname"));
} catch (Exception $e) {
    print_r($e);
}
```

私有化部署
-----

[](#私有化部署)

**私有化部署**场景需要指定你私有化的 Authing 服务的 GraphQL 端点（**不带协议头和 Path**），如果你不清楚可以联系 Authing IDaaS 服务管理员。

接口索引
----

[](#接口索引)

可用的 Authentication 方法

- 获取当前用户的用户资料: `getCurrentUser`
- 使用邮箱注册: `registerByEmail`
- 使用用户名注册: `registerByUsername`
- 使用手机号验证码注册: `registerByPhoneCode`
- 使用邮箱登录: `loginByEmail`
- 使用用户名登录: `loginByUsername`
- 使用手机号验证码登录 `loginByPhoneCode`
- 使用手机号密码登录: `loginByPhonePassword`
- 发送邮件: `sendEmail`
- 发送短信验证码: `sendSmsCode`
- 检查 token 的有效状态: `checkLoginStatus`
- 使用手机号验证码重置密码: `resetPasswordByPhoneCode`
- 使用邮件验证码重置密码: `resetPasswordByEmailCode`
- 更新用户资料: `updateProfile`
- 更新密码: `updatePassword`
- 更新手机号: `updatePhone`
- 更新邮箱: `updateEmail`
- 刷新 token: `refreshToken`
- 绑定手机号: `bindPhone`
- 解绑手机号: `unbindPhone`

详情请见： [用户认证模块](https://docs.authing.cn/v2/reference/sdk-for-php/authentication/)

管理模块包含以下子模块： [管理用户](https://docs.authing.cn/v2/reference/sdk-for-php/management/UsersManagementClient.html)

[管理角色](https://docs.authing.cn/v2/reference/sdk-for-php/management/RolesManagementClient.html)

[管理策略](https://docs.authing.cn/v2/reference/sdk-for-php/management/PoliciesManagementClient.html)

[管理权限、访问控制](https://docs.authing.cn/v2/reference/sdk-for-php/management/AclManagementClient.html)

[管理用户自定义字段](https://docs.authing.cn/v2/reference/sdk-for-php/management/UdfManagementClient.html)

获取帮助
----

[](#获取帮助)

Join us on Gitter: [\#authing-chat](https://gitter.im/authing-chat/community)

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/067d4a3729fabbce5e0d02f887f9d0d9437ef66093f32294b30236fcb0b59f60?d=identicon)[shubuzuo](/maintainers/shubuzuo)

---

Top Contributors

[![wedreamer](https://avatars.githubusercontent.com/u/43949542?v=4)](https://github.com/wedreamer "wedreamer (5 commits)")

### Embed Badge

![Health badge](/badges/shubuzuo-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/shubuzuo-sdk-php/health.svg)](https://phpackages.com/packages/shubuzuo-sdk-php)
```

###  Alternatives

[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k430.4M1.7k](/packages/nette-utils)[dgr/nohup

A library to run a command in the background, it will return the process's pid, and get it's is running status anytime in the another process, and can be stoped anytime. It support Windows, Linux and Mac osx.

531.7k](/packages/dgr-nohup)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
