iulyanp / maintenance-bundle
v1.0.0
2016-10-18 18:44 UTC
Requires
- php: >=5.6|^7.0
- symfony/framework-bundle: ~2.3|~3.0
Requires (Dev)
- phpunit/phpunit: ^5.5
This package is not auto-updated.
Last update: 2021-07-22 09:35:43 UTC
README
MaintenanceBundle
MaintenanceBundle是一个简单的包,帮助您将应用程序设置为维护模式。
安装
第1步:使用composer安装包
打开您的终端并运行以下命令之一,将包下载到您的vendor目录。
- 如果您全局安装了composer,可以运行:
$ composer require iulyanp/maintenance-bundle
- 否则您可以选择:
$ php composer.phar require iulyanp/maintenance-bundle
第2步:在您的AppKernel类中注册包
在项目的app/AppKernel.php文件中注册包
<?php
/** app/AppKernel.php */
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
...
new Iulyanp\MaintenanceBundle\IulyanpMaintenanceBundle(),
);
}
}
第3步:导入包路由
iulyanp_maintenance:
resource: "@IulyanpMaintenanceBundle/Resources/config/routing.yml"
prefix: /
第4步:配置包
为了使包知道何时将您的网站设置为维护模式,您应该对其进行配置。
iulyanp_maintenance:
enabled: false
due_date: '14-10-2017 00:00:00'
layout:
signature: 'iulyanp'
title: We are in maintenance
description: Comming back soon...
您应该使用enabled和due_date配置来选择您希望应用程序处于维护模式的时间和截止日期。通过将enabled配置更改为true来激活维护,但只有当您设置了due date配置时,您的网站才会处于维护模式。
布局参数用于更改默认标题、消息和签名。您可以在翻译文件中翻译这些配置。
注意!不要忘记在Symfony框架中激活翻译。
# config.yml
framework:
translator: { fallbacks: ["%locale%"] }
...