spiral-packages/maintenance
Composer 安装命令:
composer require spiral-packages/maintenance
包简介
Disable your application while it is updating or when you are performing maintenance.
README 文档
README
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
Requirements
Make sure that your server is configured with following PHP version and extensions:
- PHP 8.1+
- Spiral framework 3.0+
Installation
You can install the package via composer:
composer require spiral-packages/maintenance
After package install you need to register bootloader from the package.
protected const LOAD = [ // ... \Spiral\Maintenance\Bootloader\MaintenanceBootloader::class, ];
Note: if you are using
spiral-packages/discoverer, you don't need to register bootloader by yourself.
Configuration
By default, the package uses file driver for storing information about maintenance mode. If you have multiple
instances of your application you need to use cache driver with storage that will be accessed from all instances.
MAINTENANCE_DRIVER=cache MAINTENANCE_CACHE_STORAGE=null MAINTENANCE_CACHE_KEY=maintenance
Usage
Include Spiral\Maintenance\Middleware\PreventRequestInMaintenanceModeMiddleware in your application for routes that
should not have access during maintenance mode.
final class RoutesBootloader extends BaseRoutesBootloader { protected function globalMiddleware(): array { return [ \Spiral\Maintenance\Middleware\PreventRequestInMaintenanceModeMiddleware::class, // ... ]; } }
To enable maintenance mode, execute the down command:
php app.php down
By default, response code for maintenance mode is 503, but you may set custom response code
php app.php down --status=504
To disable maintenance mode, use the up command:
php app.php up
When your application is in maintenance mode the middleware
throws Spiral\Maintenance\Exception\MaintenanceModeHttpException with defined status code.
Spiral Framework allows you to pre-render a maintenance mode view that will be returned to the very beginning of the
request cycle. You may pre-render a template of your choice using App\ErrorHandler\ViewRenderer. By default, it looks
for a template in a folder app/views/exception/{statusCode}.dark.php
You can create a new view file app/views/exception/503.dark.php:
<extends:layout.base title="[[Maintenance mode]]"/> <use:element path="embed/links" as="homepage:links"/> <stack:push name="styles"> <link rel="stylesheet" href="/styles/welcome.css"/> </stack:push> <define:body> <div class="wrapper"> <img src="/images/503.svg" alt="Error 503" width="300px"/> <h2>{{ $exception->getMessage() ?? 'Maintenance mode' }}</h2> </div> </define:body>
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
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.
spiral-packages/maintenance 适用场景与选型建议
spiral-packages/maintenance 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 07 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「php」 「maintenance」 「spiral」 「maintenance-mode」 「spiral-framework」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 spiral-packages/maintenance 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 spiral-packages/maintenance 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 spiral-packages/maintenance 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
An enhanced drop-in replacement for Laravel's maintenance mode
Maintenance page plugin
Neos Content Repository Helper to rebirth orphaned nodes
Maintenance page, pretty and simple.
Artisan command for switching a Laravel 4 queue worker into maintenance mode alongside the application safely.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-22