PHPackages                             ntimes/route-time-limits - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. ntimes/route-time-limits

ActiveLibrary[HTTP &amp; Networking](/categories/http)

ntimes/route-time-limits
========================

A Laravel package for limiting time spent on routes

v1.0.0(1y ago)211MITPHPPHP &gt;=7.0

Since May 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Nazmul-Islam-Naim/route-time-limits)[ Packagist](https://packagist.org/packages/ntimes/route-time-limits)[ RSS](/packages/ntimes-route-time-limits/feed)WikiDiscussions main Synced 1mo ago

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

🕒 Laravel Route Time Limits
===========================

[](#-laravel-route-time-limits)

[![Latest Version on Packagist](https://camo.githubusercontent.com/618f18e0cf122b039b4c39cb9209a0149256e9c50dd73789d4831b042a9b5b88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e74696d65732f726f7574652d74696d652d6c696d6974732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ntimes/route-time-limits)[![Total Downloads](https://camo.githubusercontent.com/83d86fcc6835a9aa41b18efca680b7c83ceb63f879459ae22ae414d378b22094/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e74696d65732f726f7574652d74696d652d6c696d6974732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ntimes/route-time-limits)[![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

A Laravel package that allows you to set time limits on routes and track usage times based on user authentication status. This package helps you monitor and control how much time is spent on specific routes over a defined period, with different limits for authenticated and guest users.

---

📥 Installation
--------------

[](#-installation)

Install the package via composer:

```
composer require ntimes/route-time-limits
```

Publish the configuration and migrations:

```
php artisan vendor:publish --provider="NTimes\RouteTimeLimits\RouteTimeLimitsServiceProvider"
```

Run the migrations:

```
php artisan migrate
```

---

📚 Usage
-------

[](#-usage)

### 🔰 Basic Usage

[](#-basic-usage)

Add the middleware to your routes:

```
// In your routes file
Route::get('/dashboard', 'DashboardController@index')
    ->name('dashboard')
    ->middleware('route.time.limit');

// Or for route groups
Route::middleware('route.time.limit')->group(function () {
    Route::get('/admin', 'AdminController@index')->name('admin.index');
    Route::get('/admin/users', 'AdminController@users')->name('admin.users');
});
```

### ⚙️ Configuration

[](#️-configuration)

You can customize the package behavior in the `config/route_time_limits.php` file:

```
return [
    // Default maximum time allowed for all routes (in seconds)
    'default_max_time' => [
        'guest' => 300, // 5 minutes for guests
        'authenticated' => 600, // 10 minutes for authenticated users
    ],

    // How many days of data to keep in the database
    'data_retention_days' => 1,

    // Custom route configurations
    // Format: 'route_name' => ['guest' => time_in_seconds, 'authenticated' => time_in_seconds]
    'custom_routes' => [
        'admin.dashboard' => [
            'guest' => 0, // No access for guests
            'authenticated' => 900, // 15 minutes for authenticated users
        ],
        'api.users.index' => [
            'guest' => 60, // 1 minute for guests
            'authenticated' => 300, // 5 minutes for authenticated users
        ],
    ],

    // Whether to enable the middleware globally
    'enabled' => true,

    // Routes to exclude from time tracking
    'excluded_routes' => [
        'login',
        'register',
    ],

    // Whether to track by IP address for guest users
    'track_guest_by_ip' => true,

    // Identify user by this field (default: id)
    'user_identifier' => 'id',
];
```

### 🛠️ Available Commands

[](#️-available-commands)

#### 🧹 Cleanup Old Records

[](#-cleanup-old-records)

The package includes a command to clean up old records:

```
# Clean up all records
php artisan route-time-limits:cleanup

# Clean up only guest records
php artisan route-time-limits:cleanup --user-type=guest

# Clean up only authenticated user records
php artisan route-time-limits:cleanup --user-type=authenticated
```

This command is automatically scheduled to run daily, but you can also run it manually.

#### 🔄 Reset Time Limits

[](#-reset-time-limits)

For testing or administrative purposes, you can reset time limits:

```
# Reset all time limits
php artisan route-time-limits:reset --all

# Reset time limits for a specific route
php artisan route-time-limits:reset --route=admin.dashboard

# Reset time limits for a specific user
php artisan route-time-limits:reset --user-id=1
```

---

🔍 How It Works
--------------

[](#-how-it-works)

 ```
flowchart TD
    A[Route Access] --> B{Check Limits}
    B --> C{Record Exists?}
    C -->|Yes| D{Time Limit Exceeded?}
    C -->|No| E[Create Record]
    D -->|Yes| F[Return 429]
    D -->|No| G[Track Time]
    E --> G
    G --> H[Continue Request]
```

      Loading 1. When a user visits a route with the middleware applied, the package checks if there's an existing record for that route and user type (guest or authenticated).
2. If no record exists, it creates one with the default time limit (or a custom one if configured).
3. Each time the route is accessed, the time spent is tracked and added to the daily total.
4. If the total time exceeds the configured limit, a 429 (Too Many Requests) response is returned.
5. The time counter is reset daily.
6. Different time limits are applied based on whether the user is authenticated or a guest.
7. Guest users can be tracked by IP address if configured.

---

📃 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance49

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

378d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d1acc7c3bdc5a24b0c0232e1b392b9fb6f832dd57785bdd889be0d2f54b3fcf2?d=identicon)[Nazmul-Islam-Naim](/maintainers/Nazmul-Islam-Naim)

---

Top Contributors

[![Nazmul-Islam-Naim](https://avatars.githubusercontent.com/u/62320325?v=4)](https://github.com/Nazmul-Islam-Naim "Nazmul-Islam-Naim (10 commits)")

---

Tags

middlewarelaraveltimeroutetime trackingrate limitingaccess-controluser trackinglimits

### Embed Badge

![Health badge](/badges/ntimes-route-time-limits/health.svg)

```
[![Health](https://phpackages.com/badges/ntimes-route-time-limits/health.svg)](https://phpackages.com/packages/ntimes-route-time-limits)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[casbin/laravel-authz

An authorization library that supports access control models like ACL, RBAC, ABAC in Laravel.

324339.9k4](/packages/casbin-laravel-authz)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[laravel-shift/curl-converter

A command line tool to convert curl requests to Laravel HTTP requests.

935.3k](/packages/laravel-shift-curl-converter)[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)

PHPackages © 2026

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