PHPackages                             wikyyuen/authing-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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. wikyyuen/authing-php

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

wikyyuen/authing-php
====================

authing-php-sdk-update-guzzle

4.2.1(4y ago)06MITPHPPHP &gt;=5.4

Since May 20Pushed 4y agoCompare

[ Source](https://github.com/wikyyuen/authing-php-sdk-update)[ Packagist](https://packagist.org/packages/wikyyuen/authing-php)[ RSS](/packages/wikyyuen-authing-php/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (3)Versions (25)Used By (0)

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

[](#authing---php)

 [![Authing](https://camo.githubusercontent.com/9a3f542ba1ef24e21f7dcc4c9692a12c2161984eee55293be364178479f2abea/68747470733a2f2f66696c65732e61757468696e672e636f2f61757468696e672d636f6e736f6c652f61757468696e672d6c6f676f2d6e65772d32303231303932342e7376673f613d31)](https://authing.cn)

该分支将完成 php-8 的迁移，同时完全按照严格模式进行相关编码。

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` 需要 `appId`（应用 ID）：

> 你可以在此[了解如何获取 AppId](/guides/faqs/get-app-id-and-secret.md) .

```
use Authing\Auth\AuthenticationClient;

$authentication = new AuthenticationClient(function ($ops) {
    $ops->appId = "---";
});
```

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

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

$authentication = new AuthenticationClient(function ($ops) {
    $ops->appId = "---";
});
$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(function ($ops) {
    $ops->appId = "---";
});
$authentication->loginByEmail(new LoginByEmailInput("test@example.com", "123456"));

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

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

```
use Authing\Auth\AuthenticationClient;

$authentication = new AuthenticationClient(function ($ops) {
    $ops->appId = "---";
});
$authentication->setAccessToken("ACCESS_TOKEN");
```

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

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

$authentication = new AuthenticationClient(function ($ops) {
    $ops->appId = "---";
});
$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 forum: [\#authing-chat](https://forum.authing.cn/)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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.

###  Release Activity

Cadence

Every ~62 days

Total

22

Last Release

1608d ago

Major Versions

v0.0.1 → 1.0.02020-07-15

1.0.1 → 2.0.02020-10-23

2.0.1 → 4.0.02020-11-04

4.1.13 → 7.1.x-dev2021-04-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/917b9c10570415f1ce6872500c87fa5d6f1daa64e88eea12a8ae9068779bc9d4?d=identicon)[wikyyuen](/maintainers/wikyyuen)

---

Top Contributors

[![wedreamer](https://avatars.githubusercontent.com/u/43949542?v=4)](https://github.com/wedreamer "wedreamer (42 commits)")[![recallfuture](https://avatars.githubusercontent.com/u/29711565?v=4)](https://github.com/recallfuture "recallfuture (27 commits)")[![leinue](https://avatars.githubusercontent.com/u/2469688?v=4)](https://github.com/leinue "leinue (10 commits)")[![zhaoyiming0803](https://avatars.githubusercontent.com/u/25874685?v=4)](https://github.com/zhaoyiming0803 "zhaoyiming0803 (7 commits)")[![hy8262111](https://avatars.githubusercontent.com/u/42486333?v=4)](https://github.com/hy8262111 "hy8262111 (7 commits)")[![wikyyuen](https://avatars.githubusercontent.com/u/18620535?v=4)](https://github.com/wikyyuen "wikyyuen (4 commits)")[![luojielin](https://avatars.githubusercontent.com/u/29780568?v=4)](https://github.com/luojielin "luojielin (2 commits)")[![wajiao](https://avatars.githubusercontent.com/u/20143458?v=4)](https://github.com/wajiao "wajiao (1 commits)")[![lljxx1](https://avatars.githubusercontent.com/u/7993835?v=4)](https://github.com/lljxx1 "lljxx1 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wikyyuen-authing-php/health.svg)

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

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k272.7M162](/packages/google-auth)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

120220.7k1](/packages/ellaisys-aws-cognito)[clerkinc/backend-php

2755.0k](/packages/clerkinc-backend-php)[kinde-oss/kinde-auth-php

Kinde PHP SDK for authentication

2369.5k3](/packages/kinde-oss-kinde-auth-php)

PHPackages © 2026

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