PHPackages                             dotkernel/dot-totp - 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. dotkernel/dot-totp

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

dotkernel/dot-totp
==================

DotKernel TOTP authorization component

0.4(4mo ago)1853↑103.3%MITPHPPHP ~8.3.0 || ~8.4.0 || ~8.5.0CI failing

Since Jan 26Pushed 4mo agoCompare

[ Source](https://github.com/dotkernel/dot-totp)[ Packagist](https://packagist.org/packages/dotkernel/dot-totp)[ Docs](https://github.com/dotkernel/dot-totp)[ RSS](/packages/dotkernel-dot-totp/feed)WikiDiscussions 1.0 Synced today

READMEChangelog (4)Dependencies (10)Versions (9)Used By (0)

dot-totp
========

[](#dot-totp)

Dotkernel's TOTP authentication.

[![OSS Lifecycle](https://camo.githubusercontent.com/c5827ab28d7be4211bd2531689fc44d5e07f9cf60904da4c378270be1faef9e3/68747470733a2f2f696d672e736869656c64732e696f2f6f73736c6966656379636c652f646f746b65726e656c2f646f742d746f7470)](https://camo.githubusercontent.com/c5827ab28d7be4211bd2531689fc44d5e07f9cf60904da4c378270be1faef9e3/68747470733a2f2f696d672e736869656c64732e696f2f6f73736c6966656379636c652f646f746b65726e656c2f646f742d746f7470)[![PHP from Packagist (specify version)](https://camo.githubusercontent.com/bf0eb9299329ad3919cf09168c89069acf6d3431cb3ba2615f46bb830ec0863c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646f746b65726e656c2f646f742d746f74702f312e302e30)](https://camo.githubusercontent.com/bf0eb9299329ad3919cf09168c89069acf6d3431cb3ba2615f46bb830ec0863c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646f746b65726e656c2f646f742d746f74702f312e302e30)

[![GitHub issues](https://camo.githubusercontent.com/2e8b03b5e53250e28015ff2add1c6a823a306d96ba971f3d463ea2b3c5076319/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f646f746b65726e656c2f646f742d746f7470)](https://github.com/dotkernel/dot-totp/issues)[![GitHub forks](https://camo.githubusercontent.com/5e2f4862b2b95c69d7674e1f941d4ef27d6f4477e07cedba0eca2349679a807b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f646f746b65726e656c2f646f742d746f7470)](https://github.com/dotkernel/dot-totp/network)[![GitHub stars](https://camo.githubusercontent.com/98dc0484d781d6df5f4a2947c4cbe0c1109ac02cf67b241a456dcd0ba4edf2a4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f646f746b65726e656c2f646f742d746f7470)](https://github.com/dotkernel/dot-totp/stargazers)[![GitHub license](https://camo.githubusercontent.com/22a5488d5d9b1b59461a7adc458c20ebced428776d3f8ba4db0941bd3a532e28/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f646f746b65726e656c2f646f742d746f7470)](https://github.com/dotkernel/dot-totp/blob/1.0/LICENSE.md)

[![Build Static](https://github.com/dotkernel/dot-totp/actions/workflows/continuous-integration.yml/badge.svg?branch=1.0)](https://github.com/dotkernel/dot-totp/actions/workflows/continuous-integration.yml)[![codecov](https://camo.githubusercontent.com/877fc1dd761ddfe00564821edd1316142d4258f9da5845e5668074f5183cb463/68747470733a2f2f636f6465636f762e696f2f67682f646f746b65726e656c2f646f742d746f74702f67726170682f62616467652e7376673f746f6b656e3d5235506f705748765275)](https://codecov.io/gh/dotkernel/dot-totp)[![PHPStan](https://github.com/dotkernel/dot-totp/actions/workflows/static-analysis.yml/badge.svg?branch=1.0)](https://github.com/dotkernel/dot-totp/actions/workflows/static-analysis.yml)

Install
-------

[](#install)

You can install dot-totp by running the following command:

```
composer require dotkernel/dot-totp
```

Configuration
-------------

[](#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
-----

[](#usage)

### Enabling and Disabling TOTP

[](#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

[](#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:**

1. Generate a temporary Base32 secret.
2. Build a provisioning URI with a label and issuer.
3. Render the URI as a QR code.
4. Validate the code from the authenticator app.

Once validated, update the relevant properties to enable or disable TOTP.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance73

Regular maintenance activity

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.5% 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.

###  Release Activity

Cadence

Every ~1 days

Total

5

Last Release

149d ago

Major Versions

0.4 → 1.0.x-dev2026-02-05

PHP version history (2 changes)0.1PHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

0.4PHP ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1156873?v=4)[Dotkernel](/maintainers/dotkernel)[@dotkernel](https://github.com/dotkernel)

---

Top Contributors

[![SergiuBota1](https://avatars.githubusercontent.com/u/50962867?v=4)](https://github.com/SergiuBota1 "SergiuBota1 (13 commits)")[![alexmerlin](https://avatars.githubusercontent.com/u/4542449?v=4)](https://github.com/alexmerlin "alexmerlin (3 commits)")[![arhimede](https://avatars.githubusercontent.com/u/22009710?v=4)](https://github.com/arhimede "arhimede (1 commits)")

---

Tags

totpmezziodotkernel

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dotkernel-dot-totp/health.svg)

```
[![Health](https://phpackages.com/badges/dotkernel-dot-totp/health.svg)](https://phpackages.com/packages/dotkernel-dot-totp)
```

###  Alternatives

[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k51.2M339](/packages/api-platform-core)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[api-platform/state

API Platform state interfaces

274.9M136](/packages/api-platform-state)[vectorface/googleauthenticator

Google Authenticator 2-factor authentication

19256.5k1](/packages/vectorface-googleauthenticator)[testo/testo

A lightweight PHP testing framework.

1959.3k64](/packages/testo-testo)

PHPackages © 2026

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