PHPackages                             dakshraman/laravel-browser-guard - 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. dakshraman/laravel-browser-guard

ActiveLibrary[Security](/categories/security)

dakshraman/laravel-browser-guard
================================

A Laravel package to discourage right-click, shortcut keys, and casual DevTools access in the browser.

v1.2.0(2w ago)010MITPHPPHP ^8.1

Since Jul 4Pushed 2w agoCompare

[ Source](https://github.com/dakshraman/laravel-browser-guard)[ Packagist](https://packagist.org/packages/dakshraman/laravel-browser-guard)[ RSS](/packages/dakshraman-laravel-browser-guard/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (12)Versions (4)Used By (0)

Browser Guard
=============

[](#browser-guard)

A Laravel package that discourages:

- right click / context menu
- selected shortcut keys like `F12`, `Ctrl+Shift+I`, `Ctrl+Shift+J`, `Ctrl+Shift+C`, `Ctrl+U`
- casual DevTools opening through simple browser-side detection

Important note
--------------

[](#important-note)

This package does **not** provide real security. Anything running in the browser can be bypassed by a determined user. Use it only as a UI deterrent, not as a protection layer for sensitive data.

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10, 11, 12, or 13

Installation
------------

[](#installation)

```
composer require dakshraman/laravel-browser-guard
php artisan browser-guard:install
```

The install command will publish config and assets, then walk you through configuration interactively:

```
Which guards would you like to enable?

 Block right-click / context menu? (yes/no) [yes]:
 > yes
 Block keyboard shortcuts (F12, Ctrl+U, etc.)? (yes/no) [yes]:
 > yes
 Detect DevTools opening? (yes/no) [yes]:
 > yes

How should Browser Guard run?
 [global]   - Script loads on every page with @browserGuardScripts
 [middleware]- Script loads only on routes using browser.guard middleware

 Select mode [global]:
 [0] global
 [1] middleware
 > 0

 Show alert when a guard is triggered? (yes/no) [yes]:
 > yes
 Alert message [This action is disabled on this page.]:
 >

 What should happen when DevTools is detected?
 DevTools action [alert]:
 [0] alert
 [1] redirect
 [2] blank
 > 0

Configuration saved to config/browser-guard.php

```

### Skip interactive prompts

[](#skip-interactive-prompts)

For CI or scripted installs, use `--skip-config`:

```
php artisan browser-guard:install --skip-config
```

### Manual publish

[](#manual-publish)

```
php artisan vendor:publish --tag=browser-guard-config
php artisan vendor:publish --tag=browser-guard-assets
```

Add the script to your layout
-----------------------------

[](#add-the-script-to-your-layout)

In your main Blade layout, just before ``:

```
@browserGuardScripts
```

Usage modes
-----------

[](#usage-modes)

### 1. Global mode

[](#1-global-mode)

```
'mode' => 'global',
```

The script will load wherever `@browserGuardScripts` exists.

### 2. Middleware mode

[](#2-middleware-mode)

```
'mode' => 'middleware',
```

Then apply the middleware only to routes you want to protect:

```
Route::middleware('browser.guard')->group(function () {
    Route::get('/protected-page', function () {
        return view('welcome');
    });
});
```

The middleware also sets `no-cache` headers to prevent browser caching of protected pages.

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

[](#configuration)

```
// Master switch
'enabled' => true,

// Mode: 'global' or 'middleware'
'mode' => 'global',

// Guards
'block_right_click' => true,
'block_shortcuts' => true,
'detect_devtools' => true,

// Alert UI
'show_alert' => true,
'alert_message' => 'This action is disabled on this page.',

// DevTools handling: 'alert' | 'redirect' | 'blank'
'devtools_action' => 'alert',
'devtools_message' => 'Developer tools detected. This page is protected.',
'devtools_redirect_url' => '/',
'devtools_check_interval' => 1000,
'devtools_threshold' => 160,
```

Custom shortcuts
----------------

[](#custom-shortcuts)

```
'shortcuts' => [
    ['key' => 'F12'],
    ['ctrl' => true, 'shift' => true, 'key' => 'I'],
    ['ctrl' => true, 'shift' => true, 'key' => 'J'],
    ['ctrl' => true, 'shift' => true, 'key' => 'C'],
    ['ctrl' => true, 'key' => 'U'],
],
```

Excluding paths
---------------

[](#excluding-paths)

```
'except_paths' => [
    'admin/api/*',
    'health-check',
],
```

Testing
-------

[](#testing)

```
composer test
```

File structure
--------------

[](#file-structure)

```
browser-guard/
├── composer.json
├── config/
│   └── browser-guard.php
├── resources/
│   ├── js/
│   │   └── browser-guard.js
│   └── views/
│       └── script.blade.php
└── src/
    ├── BrowserGuardServiceProvider.php
    ├── Commands/
    │   └── InstallBrowserGuardCommand.php
    └── Middleware/
        └── BrowserGuardMiddleware.php

```

License
-------

[](#license)

MIT

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance96

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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

Total

3

Last Release

19d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f1de933f1f20fb524eb36c6dcce05f55f8f14997d1ad471be8bc8c55fbc828f4?d=identicon)[dakshraman](/maintainers/dakshraman)

---

Top Contributors

[![dakshraman](https://avatars.githubusercontent.com/u/120021524?v=4)](https://github.com/dakshraman "dakshraman (9 commits)")

---

Tags

browserlaravelDevtoolsshortcutsguardright-click

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/dakshraman-laravel-browser-guard/health.svg)

```
[![Health](https://phpackages.com/badges/dakshraman-laravel-browser-guard/health.svg)](https://phpackages.com/packages/dakshraman-laravel-browser-guard)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k30.2M151](/packages/laravel-cashier)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M136](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M133](/packages/roots-acorn)[hasinhayder/tyro-dashboard

Tyro Dashboard - Beautiful admin dashboard for managing Tyro roles, privileges, users, and settings

5443.8k](/packages/hasinhayder-tyro-dashboard)[moonshine/moonshine

Laravel administration panel

1.3k253.1k86](/packages/moonshine-moonshine)

PHPackages © 2026

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