承接 contenir/maintenance-laminas-mvc 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

contenir/maintenance-laminas-mvc

最新稳定版本:v0.3.1

Composer 安装命令:

composer require contenir/maintenance-laminas-mvc

包简介

Laminas MVC adapter for contenir/maintenance — short-circuits dispatch with 503 when maintenance mode is active.

README 文档

README

Laminas MVC adapter for contenir/maintenance.

When the admin (Contenir CMS) toggles maintenance mode, this adapter short-circuits dispatch in the consuming Site with a 503 response — until the flag is cleared.

Install

composer require contenir/maintenance-laminas-mvc

Wire-up

1. Register the module

// config/modules.config.php
return [
    // ...other modules
    'Contenir\\Maintenance\\Laminas\\Mvc',
];

If you have laminas/laminas-component-installer installed, this happens automatically.

2. Point at the shared state file

// config/autoload/maintenance.local.php
return [
    'maintenance' => [
        // Same path the admin (Contenir CMS) is configured to write.
        'file' => '/var/www/shared/maintenance.local.php',
    ],
];

That's the minimum. With nothing else set, the adapter will return a plain 503 page with the configured message whenever maintenance is active.

3. (Optional) Bypass for operators

// config/autoload/maintenance.local.php
return [
    'maintenance' => [
        'file'   => '/var/www/shared/maintenance.local.php',
        'bypass' => static function (\Laminas\Mvc\MvcEvent $event): bool {
            // Return true to let the request through despite maintenance mode.
            // E.g. allow authenticated super-admins:
            $auth = $event->getApplication()->getServiceManager()->get('auth');
            return $auth->hasIdentity() && $auth->getIdentity()->isSuperAdmin();
        },
    ],
];

4. (Optional) Customise the response body

'maintenance' => [
    'body_template' => file_get_contents(__DIR__ . '/../templates/maintenance.html'),
    'retry_after'   => 1800, // seconds, sent as Retry-After header
],

body_template is a sprintf format string with a single %s for the escaped message text. If you need anything more elaborate (full layout, view helpers, translation), replace the MaintenanceListener service with your own factory.

Listener priority

The listener attaches at MvcEvent::EVENT_DISPATCH priority 10000 so it runs before route → controller dispatch and before any other listener that hasn't asked for higher priority. The exact value is exposed as Module::DISPATCH_PRIORITY if you need to coordinate with another listener.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固