PHPackages                             thecsea/twofactor-dir - 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. thecsea/twofactor-dir

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

thecsea/twofactor-dir
=====================

The most powerful and the simplest library to add two factor authentication by google authenticator, in every directory that you want in just one step

v1.0.14(10y ago)3125[2 issues](https://github.com/thecsea/twofactor-dir/issues)1GPL-2.0PHPPHP &gt;=5.3.0

Since Jul 28Pushed 10y ago2 watchersCompare

[ Source](https://github.com/thecsea/twofactor-dir)[ Packagist](https://packagist.org/packages/thecsea/twofactor-dir)[ Docs](http://www.thecsea.it/progetti/)[ RSS](/packages/thecsea-twofactor-dir/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (15)Used By (1)

twofactor-dir
=============

[](#twofactor-dir)

Build status: [![Build Status](https://camo.githubusercontent.com/8499d72396400848ac0e76a97c5efdedd239c2909b5a08d0a2a73c299b840b0a/68747470733a2f2f7472617669732d63692e6f72672f746865637365612f74776f666163746f722d6469722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/thecsea/twofactor-dir) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/f14b79ea9e6ffda45d7d7e7e5b6758ba16d83e5b480ed8dd6061440d974aa396/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746865637365612f74776f666163746f722d6469722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/thecsea/twofactor-dir/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/ec984eda4cfd9f8764fe6da2363a5a81f998eee7d42ef7a2287fe2b4719015f8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746865637365612f74776f666163746f722d6469722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/thecsea/twofactor-dir/?branch=master) [![Build Status](https://camo.githubusercontent.com/d160bf4324b07289a3d8db8fe32a6b376d51ef97e0020002157616948e8731bc/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746865637365612f74776f666163746f722d6469722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/thecsea/twofactor-dir/build-status/master) [![Latest Stable Version](https://camo.githubusercontent.com/009d3fcb9daa03186cb2bcbc2d3665875c5347901769fccccc3d0479c30fb5f7/68747470733a2f2f706f7365722e707567782e6f72672f746865637365612f74776f666163746f722d6469722f762f737461626c65)](https://packagist.org/packages/thecsea/twofactor-dir) [![Total Downloads](https://camo.githubusercontent.com/487232a6cc725e5c3af0350fd61d2861b05602b0fb9882e36ce9dbd384beca92/68747470733a2f2f706f7365722e707567782e6f72672f746865637365612f74776f666163746f722d6469722f646f776e6c6f616473)](https://packagist.org/packages/thecsea/twofactor-dir) [![Latest Unstable Version](https://camo.githubusercontent.com/8278b0b45ab41083f89dca59b0f6e9023f976e2c03b24af435d639ae9b9f7e6b/68747470733a2f2f706f7365722e707567782e6f72672f746865637365612f74776f666163746f722d6469722f762f756e737461626c65)](https://packagist.org/packages/thecsea/twofactor-dir) [![License](https://camo.githubusercontent.com/e82875916604ece3f5d21f421162f6617b32c4ee3670c2e5fa0fd61f7810b7d5/68747470733a2f2f706f7365722e707567782e6f72672f746865637365612f74776f666163746f722d6469722f6c6963656e7365)](https://packagist.org/packages/thecsea/twofactor-dir)

The most powerful and the simplest library to add two factor authentication by google authenticator, for every directory that you want in just one step

- Add two factor in different directory with different secret
- Lock all pages and files until the correct code is inserted
- Set automatically mod rewrite redirect to insert code page until the correct code is inserted
- Update you htaccess automatically
- Easily installation in each dir in just one step
- Only one software installation location to allow you to manage it easily
- You can always set up two factor in new directories without change other installations, keeping the same software installation location

\#Constraints

- **httacces and mod rewrite needed**
- php write permission
- the date time on the server must be synchronized (only 1 minute of margin)

\#Download ##Get/update composer This library require composer (download composer here )

Update composer

`php composer.phar self-update`

\##Download

Download via composer require (we suggest to create a dedicated directory for this)

`php composer.phar require thecsea/twofactor-dir`

or insert library as dependency in your composer project

`thecsea/twofactor-dir": "1.0.*`

in the last case you have to install or update you project

`php composer.phar install`

or

`php composer.phar update`

**N.B. If you don't have access to server terminal you can perform installation on your pc and upload all via ftp**

\##Update twofactor-dir

You can update *twofactor-dir* (according to version limit set in `composer.json`)

`php composer.phar update`

\#Use

\##Installation You can set different different directory keeping only one software location, but **you mustn't change it**

\###Set up twofactor-dir

1. Give php write permissions to the directory where you want to set up *twofactor-dir*
2. Enable htacces and mod rewrite
3. open via a browser the following page and insert the directory position (preferably absolute link)

`vendor/thecsea/twofactor-dir/files/install.php`

after this you will see new files and htaccess updated

We suggest to hide via htaccess the *twofactor-dir* installation directory

\###First Use You can get secret or QR code on `YOUR_DIR/get_qr.php`. We suggest to use a https connection

After linked a device we suggest to hide `get_qr.php` for not logged users in the following way:

**CAUTION** Comment `RewriteRule ^get_qr.php$ get_qr.php [L,QSA]` on htaccess generated after get qr for the first time, so you are able to get qr (to add more devices) only after login

\##Use When you try to access to each page of the directory you will be redirected to insert code page, when you insert code you will be logged until the session is closed.

You can add new devices after login (insert code page) calling `YOUR_DIR/get_qr.php`

\##Customize

Obviously you can customize interface modifying:

- redirect.php
- get\_qr.php

\##Disable You can disable *twofactor-dir* temporarily commenting the redirect instructions on `.htaccess`

\##Uninstall To unistall *twofactor-dir* for a directory you have to remove the following files from your dir:

- get\_qr.php
- redirect.php
- secret.php

and remove the *twofactor-dir* lines (marked) from `.htacces`

**CAUTION: You must keep the *twofactor-dir* installation (installation downloaded by composer) if you have set up it in other directories**

Credits
=======

[](#credits)

- [Sonata GoogleAuthenticator](https://github.com/sonata-project/GoogleAuthenticator): php library to use twofactor in the same way of google authenticator

\#By [thecsea.it](http://www.thecsea.it)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~5 days

Recently: every ~15 days

Total

14

Last Release

3878d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/280e8cda025e47f1005450604314ec83a21dc771a405e64c071c9f4f5f822224?d=identicon)[carduz](/maintainers/carduz)

---

Top Contributors

[![carduz](https://avatars.githubusercontent.com/u/10631614?v=4)](https://github.com/carduz "carduz (27 commits)")

---

Tags

googleAuthenticationdirectorytwofactor

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thecsea-twofactor-dir/health.svg)

```
[![Health](https://phpackages.com/badges/thecsea-twofactor-dir/health.svg)](https://phpackages.com/packages/thecsea-twofactor-dir)
```

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k272.7M162](/packages/google-auth)[hwi/oauth-bundle

Support for authenticating users using both OAuth1.0a and OAuth2 in Symfony.

2.4k21.5M68](/packages/hwi-oauth-bundle)[hybridauth/hybridauth

PHP Social Authentication Library

3.4k8.5M93](/packages/hybridauth-hybridauth)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[kreait/firebase-tokens

A library to work with Firebase tokens

24040.8M14](/packages/kreait-firebase-tokens)[opauth/opauth

Multi-provider authentication framework for PHP

1.6k783.4k58](/packages/opauth-opauth)

PHPackages © 2026

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