PHPackages                             divineomega/laravel-route-restrictor - 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. divineomega/laravel-route-restrictor

Abandoned → [jord-jd/laravel-route-restrictor](/?search=jord-jd%2Flaravel-route-restrictor)Library[Authentication &amp; Authorization](/categories/authentication)

divineomega/laravel-route-restrictor
====================================

Laravel middleware to restrict a site or specific routes using HTTP basic authentication

v4.1.0(4w ago)44.4k21LGPL-3.0-onlyPHPPHP &gt;=5.5.9CI passing

Since Sep 1Pushed 4w ago1 watchersCompare

[ Source](https://github.com/Jord-JD/laravel-route-restrictor)[ Packagist](https://packagist.org/packages/divineomega/laravel-route-restrictor)[ Docs](https://github.com/Jord-JD/laravel-route-restrictor)[ GitHub Sponsors](https://github.com/DivineOmega)[ RSS](/packages/divineomega-laravel-route-restrictor/feed)WikiDiscussions master Synced 2w ago

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

🚫 Laravel Route Restrictor
==========================

[](#-laravel-route-restrictor)

Laravel Route Restrictor is middleware designed to restrict an entire site or specific routes using HTTP Basic Authentication. It is compatible with Laravel 5.1 through 13.

Setup
-----

[](#setup)

1. Run `composer require jord-jd/laravel-route-restrictor`.
2. On Laravel 5.4 and earlier, add `JordJD\LaravelRouteRestrictor\Providers\LaravelRouteRestrictorServiceProvider::class` to the `$providers` array in your `config/app.php` file. Newer Laravel versions discover it automatically.
3. Run `php artisan vendor:publish --provider="JordJD\LaravelRouteRestrictor\Providers\LaravelRouteRestrictorServiceProvider"`.
4. Add `\JordJD\LaravelRouteRestrictor\Http\Middleware\BasicAuthentication::class` to the `$middleware` array in your `app/Http/Kernel.php` file.
5. Add `'routeRestrictor' => \JordJD\LaravelRouteRestrictor\Http\Middleware\BasicAuthentication::class` to the `$routeMiddleware` array in your `app/Http/Kernel.php` file.
6. If a CGI/FastCGI server does not forward the `Authorization` header, configure the server to forward it. For Apache, add `RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]` immediately below `RewriteEngine On` in `public/.htaccess`.

The middleware reads credentials from the request rather than PHP globals, so it also works safely with long-running application servers and test clients.

Global restriction
------------------

[](#global-restriction)

In order to restrict all routes in your Laravel application, just add the global username and password to your `.env` file as follows. Ensure you change the `username` and `password` values.

```
ROUTE_RESTRICTOR_GLOBAL_USERNAME=username
ROUTE_RESTRICTOR_GLOBAL_PASSWORD=password

```

Your entire application will then be protected by these details, unless a route specific restriction is in place.

Alternatively, you can modify the global restriction username and password in your `config/laravel-route-restrictor.php` configuration file.

Restricting specific routes
---------------------------

[](#restricting-specific-routes)

To restrict specific routes, you must edit your routes file. Simply surround the route or routes you want to restrict with the following route group code. Ensure you change the `username` and `password` middleware parameters.

```
Route::group(['middleware' => 'routeRestrictor:username,password'], function () {
    // Route(s) to restrict go here
});
```

Note: If you have both route specific restrictions and a global restriction, both will work, but route specific restrictions will take priority.

Excluding specific routes from restriction
------------------------------------------

[](#excluding-specific-routes-from-restriction)

If you wish to exclude one or more routes from restriction, you must edit your routes file. Simply surround the route or routes you want to exclude with the following route group code.

```
Route::group(['middleware' => 'routeRestrictor:disable'], function () {
    // Route(s) to exclude from restriction go here
});
```

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance94

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~240 days

Recently: every ~683 days

Total

16

Last Release

28d ago

Major Versions

v1.0.1 → v2.0.02017-03-29

v2.3.1 → v3.0.02026-02-14

v3.0.0 → v4.0.02026-02-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/c580cdf7c14898fff179cdfc1085892091d5d2f49d917873a12365af9ac77c93?d=identicon)[Jord-JD](/maintainers/Jord-JD)

---

Top Contributors

[![Jord-JD](https://avatars.githubusercontent.com/u/650645?v=4)](https://github.com/Jord-JD "Jord-JD (24 commits)")[![jbrooksuk](https://avatars.githubusercontent.com/u/246103?v=4)](https://github.com/jbrooksuk "jbrooksuk (4 commits)")

---

Tags

basic-authenticationlaravellaravel-5-packagelaravel-middlewaremiddlewareroutinglaravelpasswordrestrictionpassword restrictionbasic authentication

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/divineomega-laravel-route-restrictor/health.svg)

```
[![Health](https://phpackages.com/badges/divineomega-laravel-route-restrictor/health.svg)](https://phpackages.com/packages/divineomega-laravel-route-restrictor)
```

###  Alternatives

[unopim/unopim

UnoPim Laravel PIM

10.8k2.5k](/packages/unopim-unopim)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21327.3k4](/packages/ecotone-laravel)[aurorawebsoftware/aauth

Laravel Aauth

412.4k1](/packages/aurorawebsoftware-aauth)

PHPackages © 2026

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