brickx/laravel-filament-maintenance 问题修复 & 功能扩展

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

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

brickx/laravel-filament-maintenance

最新稳定版本:1.1.2

Composer 安装命令:

composer require brickx/laravel-filament-maintenance

包简介

Simple plugin to toggle maintenance mode from Filament

README 文档

README

GitHub Tests Action Status Packagist Downloads

⚠️ IMPORTANT

This repository has been archived, as a newer version for Filament v3 can be found here: Maintenance Switch.

I'll try my best to make this new repository compatible with Filament v2 as well, but I can't guarantee when that will happen. Feel free to use this archived version in the meantime.

This plugin allows you to easily toggle maintenance mode from your Filament Admin Panel. You can also set a secret token to bypass the maintenance mode.

Requirements

This plugin was developed for Filament v2, and will soon be archived.

If you're using Filament v3, please check out the new repository for the plugin: brickx/maintenance-switch.

Installation

You can install the package via composer:

composer require brickx/laravel-filament-maintenance

You can publish the config file with:

php artisan vendor:publish --tag="filament-maintenance-config"

This is the contents of the published config file:

return [
    'secret' => null,
    'refresh' => false,
    'permissions' => false,
    'role' => false,
    'tiny_toggle' => false,
];

You can publish the translations with:

php artisan vendor:publish --tag="filament-maintenance-translations"

Optionally, you can publish the views using:

php artisan vendor:publish --tag="filament-maintenance-views"

Setup

An optional step (but highly recommended) is to modify the App\Http\Middleware\PreventRequestsDuringMaintenance class to add the following code:

use Illuminate\Foundation\Http\MaintenanceModeBypassCookie;
use Illuminate\Http\RedirectResponse;

...

protected function bypassResponse(string $secret) : RedirectResponse
{
    return redirect('admin')->withCookie(
        MaintenanceModeBypassCookie::create($secret)
    );
}

This is because Laravel's default maintenance middleware will redirect to the / route, which feels weird for the user. Of course, you can redirect to any URL you want.

Usage

The plugin will add a toggle button to your Filament Admin Panel, right before the search bar.

Clicking it will trigger the php artisan down command if the website is live, and the php artisan up command otherwise.

Secret Token

You can set a secret token in the config file. If you do so, you will be able to bypass the maintenance mode by visiting the following URL: https://your-domain.test/{secret}.

If the secret key is set to null, a random one will be generated on the fly each time the maintenance mode is activated.

Refresh Interval

If you want to instruct browsers to refresh pages after a certain amount of time, you can set the refresh key in the config file.

When set to false, no Refresh HTTP header will be sent. You can specify an integer to define the number of seconds before reloading pages under maintenance mode.

Visibility

By default, any logged-in user will be able to toggle the maintenance mode.

If you want to restrict maintenance mode toggling to certain users, you can set the permissions key in the config file.

The plugin will use Laravel's default authorization system to check for permissions, via the can method on the User model. It will also work well with Spatie's Laravel Permission package.

Todo

  • Fix toggle button styling not properly updating when maintenance mode is disabled.
  • Improve the UX by directly adding the maintenance cookie from the Livewire component (instead of redirecting to the matching URL).

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

brickx/laravel-filament-maintenance 适用场景与选型建议

brickx/laravel-filament-maintenance 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13.05k 次下载、GitHub Stars 达 15, 最近一次更新时间为 2023 年 05 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 13.05k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 15
  • 点击次数: 35
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-26