bretrzaun/maintenance-bundle 问题修复 & 功能扩展

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

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

bretrzaun/maintenance-bundle

最新稳定版本:0.5.0

Composer 安装命令:

composer require bretrzaun/maintenance-bundle

包简介

Bundle for maintenance switch in Symfony applications

README 文档

README

Tests Latest Stable Version Total Downloads License

Installation

composer require bretrzaun/maintenance-bundle 

Register bundle in config/bundles.php:

\BretRZaun\MaintenanceBundle\MaintenanceBundle::class => ['all' => true]

Configuration

Create the following configuration file

# config/packages/maintenance.yaml maintenance: enabled: false template: 'maintenance.html.twig' # Maintenance window start from: 2018-12-01 00:00:00 # Maintenance window end until: 2018-12-03 00:00:00 # IP addresses allowed to access during maintenance # Supports: # - Wildcards: 10.*.*.* or 192.168.*.* # - CIDR notation: 192.168.1.0/24 # - IPv6: 2001:db8::/32 # - Exact IPs: 192.168.1.1 allowed_ip: - '10.*.*.*' # All 10.x.x.x IPs - '192.168.1.0/24' # Entire /24 network - '2001:db8::/32' # IPv6 network - '203.0.113.42' # Single IP

Options

  • enabled: if set to true manually activates the maintenance mode
  • template: template to render, when maintenance mode is activated
  • from: begin maintenance mode at the given date/time (only when 'enabled' is false)
  • until: end maintenance mode at the given date/time (only when 'enabled' is false)
  • allowed_ip: list of IP addresses who can access the application even in maintenance mode

Template

The bundle has a default maintenance template (see src/Resources/views/maintenance.html.twig).

You can use your own template (see configuration). In case your maintenance template extends from a parent layout you might want to exclude certain parts while in maintenance (e.g. a menu). This can be done with like so:

 {% if not maintenance_mode() %} ... {% endif %}

If the option "allowed_ip" is used, certain users can access the application even it is in maintenance mode. To make these users aware of this you can add the following to the layout template:

{% if maintenance_mode_allowed() %} <div class="alert alert-warning">Maintenance mode is activated!</div> {% endif %}

统计信息

  • 总下载量: 32.99k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固