PHPackages                             djbdeveloper/laravel-anti-replay - 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. [Security](/categories/security)
4. /
5. djbdeveloper/laravel-anti-replay

ActiveLibrary[Security](/categories/security)

djbdeveloper/laravel-anti-replay
================================

A simple anti-replay middleware for Laravel applications that is compatible with Vue hash routes.

v1.0.2(10mo ago)04MITBladePHP ^7.4|^8.0

Since Jun 25Pushed 10mo agoCompare

[ Source](https://github.com/DJB-Developer/laravel-anti-replay)[ Packagist](https://packagist.org/packages/djbdeveloper/laravel-anti-replay)[ Docs](https://github.com/djbdeveloper/laravel-anti-replay)[ RSS](/packages/djbdeveloper-laravel-anti-replay/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Anti-Replay Middleware
==============================

[](#laravel-anti-replay-middleware)

一个简单的 Laravel 防重放攻击中间件，它通过一个用户交互页面进行验证，并与 Vue.js 等前端框架的哈希（#）路由模式兼容。

功能
--

[](#功能)

- 防止机器人和简单的重放攻击。
- 在不丢失 URL 哈希片段的情况下重定向用户。
- 可通过用户点击按钮进行验证。
- 视图文件可发布，方便用户自定义样式。

安装
--

[](#安装)

通过 Composer 安装:

```
composer require djbdeveloper/laravel-anti-replay
```

对于 Laravel 5.5+，服务提供者会自动注册。如果你需要手动注册，请将以下行添加到 `config/app.php` 的 `providers` 数组中:

```
DJBDeveloper\LaravelAntiReplay\Providers\AntiReplayServiceProvider::class,
```

使用方法
----

[](#使用方法)

这个包注册了一个名为 `anti.replay` 的路由中间件。你可以将其应用于任何需要保护的路由或路由组。

**重要提示**: 此包依赖 Laravel 的 Session 功能。请确保你应用的路由（或路由组）已启用 `web` 中间件。

### 应用于单个路由

[](#应用于单个路由)

这是最常见的用法，例如保护你的单页应用（SPA）入口。

在 `routes/web.php` 中:

```
Route::get('/', function () {
    return view('your-spa-entry-point');
})->middleware(['web', 'anti.replay']);
```

### 应用于路由组

[](#应用于路由组)

```
Route::group(['middleware' => ['web', 'anti.replay']], function () {
    Route::get('/', function () {
        // ...
    });
    Route::get('/dashboard', function () {
        // ...
    });
});
```

自定义视图
-----

[](#自定义视图)

如果你想修改验证页面的外观，可以发布视图文件：

```
php artisan vendor:publish --provider="DJBDeveloper\LaravelAntiReplay\Providers\AntiReplayServiceProvider" --tag="views"
```

这会将 `verification.blade.php` 文件复制到你的 `resources/views/vendor/anti-replay` 目录下，你可以在那里自由编辑它。

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance54

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

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

Total

2

Last Release

321d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/52d6712a3da809026ffaf3001e80924b8def0fb1135d2b514547e61d9f15dc7f?d=identicon)[DJB-Developer](/maintainers/DJB-Developer)

---

Top Contributors

[![DJB-Developer](https://avatars.githubusercontent.com/u/143083136?v=4)](https://github.com/DJB-Developer "DJB-Developer (5 commits)")

---

Tags

middlewarelaravelsecuritycsrfvueanti-replayhash-routing

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/djbdeveloper-laravel-anti-replay/health.svg)

```
[![Health](https://phpackages.com/badges/djbdeveloper-laravel-anti-replay/health.svg)](https://phpackages.com/packages/djbdeveloper-laravel-anti-replay)
```

###  Alternatives

[tzsk/otp

A secure, database-free One-Time Password (OTP) generator and verifier for PHP and Laravel.

241641.4k1](/packages/tzsk-otp)[laragear/poke

Keep your forms alive, avoid TokenMismatchException by gently poking your Laravel app

2211.5k](/packages/laragear-poke)

PHPackages © 2026

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