nuboxdevcom/maintenance-bundle

此包已被废弃,不再维护。没有建议的替代包。

Symfony 3.x 4.x 维护包

安装: 116

依赖者: 0

建议者: 0

安全: 0

星星: 2

关注者: 1

分支: 0

语言:CSS

类型:symfony-bundle

2.0.3 2018-01-24 14:37 UTC

This package is auto-updated.

Last update: 2021-01-09 17:47:34 UTC


README

SensioLabsInsight

License Latest Stable Version

需求

  • PHP >=7.1
  • symfony/framework-bundle >= 3.4 || ^4.0
  • Twig ^2.4

⚠️ 注意:3.4版本之前的 Symfony

请使用 ^1.x 分支版本。

2.x 版本与低于 symfony 3.4 的版本不兼容

安装

使用 Composer 简单易行,运行

$ composer require nuboxdevcom/maintenance-bundle

简单配置

在此处输入您的 IP,以便在维护期间访问您的网站。

在 config/ndc_maintenance.yaml

ndc_maintenance:
    authorized_ips:
        - '127.0.0.1'
        - 'your.ip.domain.name.example'

配置

Symfony Flex 会处理一切!

如何使用

在您的模板中,添加以下内容以知道网站是否处于维护模式

    {% if isMaintenanceMode() %}
        <p class="text-center bg-danger"><strong>Your site is in maintenance mode...</strong></p>
    {% endif %}

isMaintenanceMode() 返回布尔值 true 或 false。

如果您想激活维护模式,您需要调用以下方法

    $this->get('maintenance.service')->enableMaintenanceAction();

或者

    $this->get('maintenance.service')->disableMaintenanceAction();

要禁用维护模式。

如果您想从控制器中知道维护是否启用,请使用此方法

    $this->get('maintenance.service')->isMaintenanceMode();

isMaintenanceMode() 返回布尔值 true 或 false。

如何更改维护页面的视图

如果您想更改视图,请创建一个新的视图文件

    templates/bundles/NDCMaintenanceBundle/maintenance.html.twig