atournayre / maintenance-bundle
Symfony 4的维护包
dev-master
2021-03-28 10:36 UTC
Requires
- php: >=7.1.3
- atournayre/dotenv-editor: v1.2.*
- symfony/config: 4.4.*
- symfony/console: 4.4.*
- symfony/dependency-injection: 4.4.*
- symfony/http-foundation: 4.4.*
- symfony/http-kernel: 4.4.*
- twig/twig: ^1.41|^2.10|^3.0
Requires (Dev)
Conflicts
This package is auto-updated.
Last update: 2024-09-26 21:33:31 UTC
README
维护包有助于管理软件维护。
这个包是做什么的?
使用此包来启用/禁用维护和管理选项。
入门指南
$ composer require atournayre/maintenance-bundle
配置
启用包
# config/bundles.php return [ // ... Atournayre\MaintenanceBundle\AtournayreMaintenanceBundle::class => ['all' => true], // ... ];
配置.env文件
# .env / .env.local.php return array ( // ... // MAINTENANCE_IS_ENABLED : true / false 'MAINTENANCE_IS_ENABLED' => true, // MAINTENANCE_START_DATETIME : "2021-03-25 00:00:00" / "2021-03-25" 'MAINTENANCE_START_DATETIME' => "2021-03-25 00:00:00", // MAINTENANCE_AUTHORIZED_IPS : "localhost,127.0.0.1" 'MAINTENANCE_AUTHORIZED_IPS' => "localhost", // ... );
添加到services.yaml的配置
# config/services.yaml parameters: atournayre_maintenance.is_enabled: '%env(MAINTENANCE_IS_ENABLED)%' atournayre_maintenance.start_date_time: '%env(MAINTENANCE_START_DATETIME)%' atournayre_maintenance.authorized_ips: '%env(MAINTENANCE_AUTHORIZED_IPS)%'
覆盖模板
使用Symfony 4.4.*?
$ mkdir -p templates/bundles/AtournayreMaintenanceBundle
$ cp -r vendor/atournayre/maintenance-bundle/Resources/views/. templates/bundles/AtournayreMaintenanceBundle
模板现在可以自定义了!
用法
安排维护
使用以下命令在将来添加维护。
$ php bin/console maintenance --start="2021-01-01 12:00:00"
启用
使用以下命令启用维护。
$ php bin/console maintenance --enable
禁用
使用以下命令禁用维护。
$ php bin/console maintenance --disable
添加授权IP
如果想让应用程序处于维护状态,但排除特定的IP,请使用以下命令。
适用于IPv4和IPv6。
$ php bin/console maintenance --add-ip="127.0.0.1"
清理IP
使用以下命令重置授权IP。
$ php bin/console maintenance --clean-ips
导出IP
不记得哪些IP被授权了吗?
使用以下命令导出授权IP。
$ php bin/console maintenance --dump-ips
调试
使用以下命令查看维护配置。
$ php bin/console maintenance --debug
多重
您可以同时使用多个指令。
$ php bin/console maintenance --enable --clean-ips --add-ip="127.0.0.1"
在这个例子中,将启用维护,重置旧的授权IP,并添加一个新的。