PHPackages                             cleaniquecoders/laravel-expiry - 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. cleaniquecoders/laravel-expiry

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

cleaniquecoders/laravel-expiry
==============================

Enable expiry on user's account and user's password.

2.3.0(1mo ago)1101[3 PRs](https://github.com/cleaniquecoders/laravel-expiry/pulls)MITPHPPHP ^8.1 | ^8,2 | ^8.3 | ^8.4CI failing

Since Mar 26Pushed 1mo agoCompare

[ Source](https://github.com/cleaniquecoders/laravel-expiry)[ Packagist](https://packagist.org/packages/cleaniquecoders/laravel-expiry)[ GitHub Sponsors]()[ RSS](/packages/cleaniquecoders-laravel-expiry/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (28)Versions (13)Used By (0)

Laravel Expiry
==============

[](#laravel-expiry)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ff491ff05f1e31b876052740199e618dd1b8f9b52edd53eaf3c6365da2af69b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636c65616e69717565636f646572732f6c61726176656c2d6578706972792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cleaniquecoders/laravel-expiry) [![PHPStan](https://github.com/cleaniquecoders/laravel-expiry/actions/workflows/phpstan.yml/badge.svg)](https://github.com/cleaniquecoders/laravel-expiry/actions/workflows/phpstan.yml) [![Run Tests](https://github.com/cleaniquecoders/laravel-expiry/actions/workflows/run-tests.yml/badge.svg)](https://github.com/cleaniquecoders/laravel-expiry/actions/workflows/run-tests.yml) [![Fix PHP Code Style Issues](https://github.com/cleaniquecoders/laravel-expiry/actions/workflows/fix-styling.yml/badge.svg)](https://github.com/cleaniquecoders/laravel-expiry/actions/workflows/fix-styling.yml) [![Total Downloads](https://camo.githubusercontent.com/6c7c2b870722cf203e3a8600c5b165c63f332249209f2ac08b83c33de1fffc16/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c65616e69717565636f646572732f6c61726176656c2d6578706972792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cleaniquecoders/laravel-expiry)

`cleaniquecoders/laravel-expiry` is a Laravel package that enables expiration for user accounts and passwords with seamless middleware and event-driven support.

---

Features
--------

[](#features)

- **Account Expiry**: Middleware to check and handle expired accounts.
- **Password Expiry**: Middleware to enforce password expiration policies.
- **Event Listeners**: Automatically trigger events when accounts or passwords expire.

---

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

[](#installation)

Install the package via Composer:

```
composer require cleaniquecoders/laravel-expiry
```

Publish and run the migration files to add the necessary expiry columns:

```
php artisan vendor:publish --tag=laravel-expiry-migrations
php artisan migrate
```

### Middleware Registration

[](#middleware-registration)

The package automatically registers the following middleware in your application:

- **`account.expiry`**: Handles account expiry checks.
- **`password.expiry`**: Handles password expiry checks.

---

Usage
-----

[](#usage)

### Apply Middleware

[](#apply-middleware)

Use the middleware in your routes to enforce expiry checks:

```
Route::middleware(['account.expiry', 'password.expiry'])->group(function () {
    Route::get('/protected-route', [SomeController::class, 'index']);
});
```

### Event Listeners

[](#event-listeners)

The package provides a configuration-driven approach to managing event listeners. By default, the following events and listeners are configured:

#### Default Event-to-Listener Mapping

[](#default-event-to-listener-mapping)

The configuration (`config/laravel-expiry.php`) includes the following mappings:

```
'events' => [
    \CleaniqueCoders\LaravelExpiry\Events\ExpiredAccount::class => [
        \CleaniqueCoders\LaravelExpiry\Listeners\LogoutOnExpired::class,
    ],
    \CleaniqueCoders\LaravelExpiry\Events\ExpiredPassword::class => [
        \CleaniqueCoders\LaravelExpiry\Listeners\LogoutOnExpired::class,
    ],
],
```

#### Handling Events

[](#handling-events)

The package automatically registers these events and listeners. You can modify or extend the behaviour by updating the configuration file.

For example, when a user's account or password expires:

- The **`ExpiredAccount`** or **`ExpiredPassword`** event is triggered.
- The **`LogoutOnExpired`** listener handles these events by logging the user out.

#### Customising Listeners

[](#customising-listeners)

To add custom listeners for these events, update the configuration file (`config/laravel-expiry.php`):

```
'events' => [
    \CleaniqueCoders\LaravelExpiry\Events\ExpiredAccount::class => [
        \App\Listeners\YourCustomListener::class,
    ],
    \CleaniqueCoders\LaravelExpiry\Events\ExpiredPassword::class => [
        \App\Listeners\YourCustomListener::class,
    ],
],
```

With this setup, the package makes it easy to integrate custom logic for handling expiry events.

---

Testing
-------

[](#testing)

To run the test suite, use the following command:

```
vendor/bin/pest --testdox
```

The package is fully tested with PestPHP to ensure reliability.

---

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

[](#contributing)

Thank you for considering contributing to `cleaniquecoders/laravel-expiry`. Contributions are welcome and appreciated!

### Reporting Bugs

[](#reporting-bugs)

If you find a bug, you can either:

- Submit a pull request with a failing test case.
- Create an issue describing the problem clearly with steps to reproduce it.

### Coding Style

[](#coding-style)

The package follows **PSR-2** coding standards and **PSR-4** autoloading.

---

License
-------

[](#license)

This package is open-source software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance90

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 81.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 ~274 days

Recently: every ~121 days

Total

9

Last Release

43d ago

Major Versions

v1.1.0 → 2.0.02024-03-21

PHP version history (3 changes)v1.0.0PHP &gt;=7.3

2.0.0PHP ^8.1 | ^8,2 | ^8.3

2.2.0PHP ^8.1 | ^8,2 | ^8.3 | ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/b57069d0f4b634f65eccc6e5d5848990e25968d45ec2cf46d626c6a4658f944b?d=identicon)[nasrulhazim.m](/maintainers/nasrulhazim.m)

---

Top Contributors

[![nasrulhazim](https://avatars.githubusercontent.com/u/10341422?v=4)](https://github.com/nasrulhazim "nasrulhazim (49 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

laravelphpuser-expirylaravelpackagepassworduseraccountexpiry

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/cleaniquecoders-laravel-expiry/health.svg)

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k16.4M48](/packages/lab404-laravel-impersonate)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[laragear/two-factor

On-premises 2FA Authentication for out-of-the-box.

339785.3k8](/packages/laragear-two-factor)[rickycezar/laravel-jwt-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

24117.6k](/packages/rickycezar-laravel-jwt-impersonate)

PHPackages © 2026

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