cleaniquecoders/laravel-expiry 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cleaniquecoders/laravel-expiry

Composer 安装命令:

composer require cleaniquecoders/laravel-expiry

包简介

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

README 文档

README

Latest Version on Packagist PHPStan Run Tests Fix PHP Code Style Issues Total Downloads

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

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

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

The package automatically registers the following middleware in your application:

  • account.expiry: Handles account expiry checks.
  • password.expiry: Handles password expiry checks.

Usage

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

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

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

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

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

To run the test suite, use the following command:

vendor/bin/pest --testdox

The package is fully tested with PestPHP to ensure reliability.

Contributing

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

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

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

License

This package is open-source software licensed under the MIT license.

cleaniquecoders/laravel-expiry 适用场景与选型建议

cleaniquecoders/laravel-expiry 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 03 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「package」 「user」 「password」 「laravel」 「account」 「expiry」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 cleaniquecoders/laravel-expiry 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cleaniquecoders/laravel-expiry 我们能提供哪些服务?
定制开发 / 二次开发

基于 cleaniquecoders/laravel-expiry 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-21