dotkernel/dot-totp
Composer 安装命令:
composer require dotkernel/dot-totp
包简介
DotKernel TOTP authorization component
关键字:
README 文档
README
Dotkernel's TOTP authentication.
Install
You can install dot-totp by running the following command:
composer require dotkernel/dot-totp
Configuration
Note: These instructions are written in the style of Mezzio middleware configuration and assume the use of Doctrine ORM.
They can be adapted to any database layer or configuration style. If you are using a different framework or service container, follow the same logical steps while adjusting the syntax and configuration to match your environment.
Create a new file configuration config/autoload/totp.global.php.
return [ 'dot_totp' => [ 'options' => [ // Time step in seconds 'period' => 30, // Number of digits in the TOTP code 'digits' => 6, // Hashing algorithm used to generate the code 'algorithm' => 'sha1', ], ], ];
The values listed above are provided as defaults and may be adjusted based on your needs.
Usage
Enabling and Disabling TOTP
To enable or disable the TOTP feature, you need to add two properties to your entity: one to store the TOTP secret and another to track whether TOTP is enabled.
You can reuse the following trait in your entity:
trait TotpTrait { #[ORM\Column(name: 'totp_secret', type: 'string', length: 32, nullable: true)] protected ?string $totpSecret = null; #[ORM\Column(name: 'totp_enabled', type: 'boolean', options: ['default' => false])] protected bool $totpEnabled = false; public function enableTotp(string $secret): self { $this->totpSecret = $secret; $this->totpEnabled = true; return $this; } public function disableTotp(): self { $this->totpSecret = null; $this->totpEnabled = false; return $this; } public function isTotpEnabled(): bool { return $this->totpEnabled; } public function getTotpSecret(): ?string { return $this->totpSecret; } }
Enable TOTP
To enable TOTP, generate a temporary secret and encode it into a QR code, which the user scans with an authenticator app (e.g., Google Authenticator, Authy). The user then confirms by providing a one-time code from the app.
Steps:
- Generate a temporary Base32 secret.
- Build a provisioning URI with a label and issuer.
- Render the URI as a QR code.
- Validate the code from the authenticator app.
Once validated, update the relevant properties to enable or disable TOTP.
dotkernel/dot-totp 适用场景与选型建议
dotkernel/dot-totp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 853 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 01 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「totp」 「dotkernel」 「mezzio」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dotkernel/dot-totp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dotkernel/dot-totp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dotkernel/dot-totp 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dotkernel component based on Maxmind's geoip2/geoip2 package, using their free GeoLite2 databases to provide geographical details about an IP address.
DotKernel filter component customizing and extending laminas-filter
DotKernel input filter component extending and customizing laminas-inputfilter
PSR-11 Aura.DI container configurator for Laminas and Mezzio applications. Drop-in replacement for the archived laminas/laminas-auradi-config with PHP 8.4 and 8.5 support.
Laminas API Tools Client API Service Consumer
统计信息
- 总下载量: 853
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-29