PHPackages                             machaven/track-attempts - 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. machaven/track-attempts

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

machaven/track-attempts
=======================

Track and limit any auth, OTP, or any other type of action.

2.0.3(5y ago)34.0k↓100%1MITPHPPHP &gt;=5.4

Since Jul 2Pushed 3y ago2 watchersCompare

[ Source](https://github.com/machaven/track-attempts)[ Packagist](https://packagist.org/packages/machaven/track-attempts)[ RSS](/packages/machaven-track-attempts/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (13)Used By (0)

Track Attempts Library
======================

[](#track-attempts-library)

A handy library to track any type of action and limit the amount of attempts made in a period of time frame.

Useful things to track and limit:

- Login attempts.
- One Time Pin (OTP) attempts.
- Any thing else you want to limit or monitor.

Features
--------

[](#features)

- Track on any metric you want, like email, username, etc.
- Configurable limits.
- Multiple backend drivers:
    - Redis (Predis Client)
    - Laravel (Cache Facade)

Install
-------

[](#install)

If using with the Laravel Drivers:

Use tags for version 1.x when used with Laravel version less than 5.8

`composer require machaven/track-attempts:^1.0`

Use tags for version 2.x when used with Laravel version 5.8+

`composer require machaven/track-attempts:^2.0`

If used with predis driver:

`composer require machaven/track-attempts:^2.0`

Class Configuration
-------------------

[](#class-configuration)

Minimum Configuration

```
$config = ['driver' => 'predis', userIdentifier' => $username];
$attempts = (new \Machaven\TrackAttempts\TrackAttempts($config))->getDriver();

```

Full Configuration

```
$config = [
    'driver' => 'predis', // Driver to use ('predis' or 'laravel')
    'userIdentifier' => $username, // A variable with a unique identifier for the session/user
    'maxAttempts' => 3, // Max attempts limit
    'systemName' => 'my-website', // System Identifier used in cache key prefix.
    'ttlInMinutes' => 5, // Keep track of attempts in a five minute period.
    'actionName' => 'login', // The name of the action you are tracking.
    ];
$attempts = (new \Machaven\TrackAttempts\TrackAttempts($config))->getDriver();

```

The configuration above will create a key named: my-website:login:$username.

Predis Driver Configuration
---------------------------

[](#predis-driver-configuration)

The predis driver requires redis settings to be configured in a .env file in your project root folder.

Example .env:

```
REDIS_SCHEME=tcp
REDIS_HOST=localhost
REDIS_PASSWORD=
REDIS_PORT=6379
REDIS_DB=0
REDIS_PROFILE=3.2

```

Usage
-----

[](#usage)

Keeping count

```
>>> $attempts->increment();
=> true

```

Getting the count

```
>>> $attempts->getCount();
=> 1

```

Checking if the limit is reached

```
>>> $attempts->isLimitReached();
=> false

```

Clearing all attempts

```
>>> $attempts->clear();
=> true

```

Checking the time left before the count expires (in seconds)

```
>>> $attempts->getTimeUntilExpired();
=> 188

```

Incrementing attempts

```
>>> $attempts->increment();

```

Using increment to track and check (example of max limit of 3 attempts)

```
>>> $attempts->incrementAndCheckLimit();
=> true
>>> $attempts->incrementAndCheckLimit();
=> true
>>> $attempts->incrementAndCheckLimit();
=> true
>>> $attempts->incrementAndCheckLimit();
=> false

```

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

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 ~124 days

Recently: every ~305 days

Total

11

Last Release

1995d ago

Major Versions

1.0.6 → 2.0.02020-07-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/98b47d2137c491e2176249ada5ddcaf23ca751725844a874e90ac35f2bb4171a?d=identicon)[machaven](/maintainers/machaven)

---

Top Contributors

[![machaven](https://avatars.githubusercontent.com/u/2025469?v=4)](https://github.com/machaven "machaven (16 commits)")

---

Tags

bruteforcecounterincrementlaravelotpphpprotectionredistrackinglaravelotpauthrediscachelimittrack

### Embed Badge

![Health badge](/badges/machaven-track-attempts/health.svg)

```
[![Health](https://phpackages.com/badges/machaven-track-attempts/health.svg)](https://phpackages.com/packages/machaven-track-attempts)
```

###  Alternatives

[sametsahindogan/laravel-jwtredis

This package allows JWT-authenticated users to be stored and management in Redis with their roles, permissions, statuses and anything you want.

1221.9k](/packages/sametsahindogan-laravel-jwtredis)[lakm/nopass

Provides passwordless authentication for your laravel projects.

2213.6k2](/packages/lakm-nopass)[orchestra/auth

Auth Component for Orchestra Platform

24108.5k3](/packages/orchestra-auth)[yangjisen/laravel-cache-provider

115.8k1](/packages/yangjisen-laravel-cache-provider)[ingria/laravel-x509-auth

Laravel 5 Client Certificate auth middleware

375.6k](/packages/ingria-laravel-x509-auth)

PHPackages © 2026

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