PHPackages                             saritasa/laravel-middleware - 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. [Framework](/categories/framework)
4. /
5. saritasa/laravel-middleware

AbandonedArchivedLibrary[Framework](/categories/framework)

saritasa/laravel-middleware
===========================

Saritasa middleware for Laravel

2.1.3(1y ago)217.1k↑44.4%1MITPHPPHP &gt;=7.0

Since Apr 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Saritasa/php-laravel-middleware)[ Packagist](https://packagist.org/packages/saritasa/laravel-middleware)[ RSS](/packages/saritasa-laravel-middleware/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (4)Versions (14)Used By (0)

Laravel Middleware
==================

[](#laravel-middleware)

[![PHP CodeSniffer](https://github.com/Saritasa/php-laravel-middleware/workflows/PHP%20Codesniffer/badge.svg)](https://github.com/Saritasa/php-laravel-middleware/actions)[![Release](https://camo.githubusercontent.com/cb72daa82f3e5e2218f2b961b1e85343b8533617680cbf1453d1aa87bc760844/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73617269746173612f7068702d6c61726176656c2d6d6964646c65776172652e737667)](https://github.com/Saritasa/php-laravel-middleware/releases)[![PHPv](https://camo.githubusercontent.com/7a3ec4b7b5986ab68013686d36fe0f54c2e9ac3b858d0a0aa01df88c77d1ed8f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f73617269746173612f6c61726176656c2d6d6964646c65776172652e737667)](http://www.php.net)[![Downloads](https://camo.githubusercontent.com/4bad3d902d2ad3379653d530b6dba17e593d2febec38c8590c03b69ff452c648/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73617269746173612f6c61726176656c2d6d6964646c65776172652e737667)](https://packagist.org/packages/saritasa/laravel-middleware)

Middleware classes for Laravel

Laravel 5.x/6.x/9.x
-------------------

[](#laravel-5x6x9x)

Install the `saritasa/laravel-middleware` package:

```
$ composer require saritasa/laravel-middleware
```

**Optionally**If you use Laravel 5.4 or less, or 5.5+ with [package discovery](https://laravel.com/docs/5.5/packages#package-discovery) disabled, add the MiddlewareServiceProvider in `config/app.php`:

```
'providers' => array(
    // ...
    Saritasa\Middleware\MiddlewareServiceProvider::class,
)
```

It will register default aliases (middleware-key) for all middleware classes

Alternatively, you can just register selected middleware classes in *App\\Http\\Kernel.php* yourself

See

Available classes
-----------------

[](#available-classes)

ClassName / middleware-key

### ForceHttps / ssl

[](#forcehttps--ssl)

This middleware has 2 effects:

1. If user tries to access website over HTTP protocol, redirect him to HTTPS.
2. If request already is made over SSL, force HTTPS URL schema for all generated URLs.

Exception: if APP\_ENV is set to 'local'.

This solves 2 problems:

1. Application can be accessed via insecure protocol
2. When application is behind proxy or load balancer, which terminates SSL, standard Laravel classes do not detect it correctly, and generate HTTP links to static resources (JS, CSS) - as result browser blocks them as insecure.

### NoCache / no-cache

[](#nocache--no-cache)

Insert HTTP headers, preventing content caching on proxy or in browser.

### AdminAuthenticate / admin

[](#adminauthenticate--admin)

Checks, that user has role = 'admin'. If not, access is denied.

### AjaxOnly / ajax-only

[](#ajaxonly--ajax-only)

If request was not made via AJAX (with XMLHttpRequest), return 'Bad Request' error.

Contributing
------------

[](#contributing)

1. Create fork, checkout it
2. Develop locally as usual. **Code must follow [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/)** - run [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) to ensure, that code follows style guides
3. **Cover added functionality with unit tests** and run [PHPUnit](https://phpunit.de/) to make sure, that all tests pass
4. Update [README.md](README.md) to describe new or changed functionality
5. Add changes description to [CHANGES.md](CHANGES.md) file. Use [Semantic Versioning](https://semver.org/) convention to determine next version number.
6. When ready, create pull request

### Make shortcuts

[](#make-shortcuts)

If you have [GNU Make](https://www.gnu.org/software/make/) installed, you can use following shortcuts:

- `make cs` (instead of `php vendor/bin/phpcs`) - run static code analysis with [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)to check code style
- `make csfix` (instead of `php vendor/bin/phpcbf`) - fix code style violations with [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)automatically, where possible (ex. PSR-2 code formatting violations)
- `make test` (instead of `php vendor/bin/phpunit`) - run tests with [PHPUnit](https://phpunit.de/)
- `make install` - instead of `composer install`
- `make all` or just `make` without parameters - invokes described above **install**, **cs**, **test** tasks sequentially - project will be assembled, checked with linter and tested with one single command

Resources
---------

[](#resources)

- [Bug Tracker](http://github.com/saritasa/php-laravel-middleware/issues)
- [Code](http://github.com/saritasa/php-laravel-middleware)
- [Changes History](CHANGES.md)
- [Authors](http://github.com/saritasa/php-laravel-middleware/contributors)

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 83% 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 ~222 days

Recently: every ~478 days

Total

13

Last Release

693d ago

Major Versions

1.0.7 → 2.0.02019-05-07

### Community

Maintainers

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

---

Top Contributors

[![populov](https://avatars.githubusercontent.com/u/3766033?v=4)](https://github.com/populov "populov (39 commits)")[![maxermolenko](https://avatars.githubusercontent.com/u/11438109?v=4)](https://github.com/maxermolenko "maxermolenko (6 commits)")[![hollow-en](https://avatars.githubusercontent.com/u/87475798?v=4)](https://github.com/hollow-en "hollow-en (2 commits)")

---

Tags

laravelmiddlewarephpmiddlewarelaravel

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/saritasa-laravel-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/saritasa-laravel-middleware/health.svg)](https://phpackages.com/packages/saritasa-laravel-middleware)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M831](/packages/laravel-socialite)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k89.4M575](/packages/laravel-passport)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

76518.2M120](/packages/laravel-mcp)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[laravel/cashier

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

2.5k28.4M137](/packages/laravel-cashier)[laravel/scout

Laravel Scout provides a driver based solution to searching your Eloquent models.

1.7k53.0M584](/packages/laravel-scout)

PHPackages © 2026

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