Download the PHP package rasuvaeff/yii3-maintenance-mode without Composer

On this page you can find all versions of the php package rasuvaeff/yii3-maintenance-mode. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii3-maintenance-mode

rasuvaeff/yii3-maintenance-mode

Stable Version Total Downloads Build Static Analysis Psalm Level PHP Русская версия

Production-oriented PSR-15 maintenance middleware for Yii3. It returns HTTP 503 with Retry-After, supports safe header bypass, health-path exclusions, IPv4/IPv6 CIDR allow-lists, trusted proxies, atomic file switching, and custom responses.

Using an AI coding assistant? llms.txt contains a compact API reference ready to paste into context.

Requirements

Installation

Usage

Middleware order

Place maintenance mode before routing and authentication, but inside global error handling, request ID, observability, CORS, and security middleware. This keeps 503 responses observable and ensures middleware failures are caught.

Configuration provider

The package registers ConfigMaintenanceProvider and MaintenanceMiddleware through Yii config-plugin.

ConfigMaintenanceProvider captures immutable state when the container creates it. Use FileMaintenanceProvider when state must change without rebuilding the container.

config/di.php and config/params.php are merged automatically only when the root application uses the yiisoft/config plugin (yiisoft/app, yiisoft/app-api). Without it, wire the services by hand:

Atomic file switching

Use the installed command instead of shell redirection or deleting the file. It writes a complete temporary file and atomically renames it.

Bind the file provider in application DI:

FileMaintenanceProvider accepts strict JSON types. Missing, unreadable, malformed, or schema-invalid files currently produce disabled state. This is a legacy fail-open policy; use the atomic writer and monitor file errors rather than relying on partial manual writes.

Bypass token

Generate a high-entropy token and its SHA-256 hash:

For the literal token my-secret-token, the correct hash is:

Store only the hash and send the plaintext token over TLS in a header:

The comparison uses hash_equals(). This protects against timing attacks, not weak-token brute force. The legacy ?bypass= query parameter remains enabled for backward compatibility, but URLs may leak through logs, browser history, analytics, and referrers. Disable it in new deployments.

Health paths, CIDR, and proxies

allowedIps accepts exact IPv4/IPv6 addresses and CIDR rules. The default IP resolver only accepts a valid REMOTE_ADDR.

Exclude health endpoints and resolve forwarded client addresses only from explicitly trusted proxies:

Never trust X-Forwarded-For without a trusted-proxy allow-list.

Custom response

Implement MaintenanceResponseFactory and inject it into MaintenanceMiddleware to provide branded HTML, RFC 9457 problem details, localization, or additional headers.

The default factory returns:

API reference

API Purpose
MaintenanceMiddleware PSR-15 maintenance decision and response
MaintenanceState Immutable enabled/retry/IP/hash state
MaintenanceProvider State provider contract
ConfigMaintenanceProvider Immutable array/config-backed provider
FileMaintenanceProvider Strict JSON provider read on each request
AtomicMaintenanceFileWriter Atomic file-state replacement
MaintenanceAccessPolicy Request bypass contract
DefaultMaintenanceAccessPolicy Header/query token, IP/CIDR, path policy
ClientIpResolver Client IP resolution contract
RemoteAddrClientIpResolver Validated direct peer address
TrustedProxyClientIpResolver Trusted forwarded-address chain
MaintenanceResponseFactory Custom 503 response contract
DefaultMaintenanceResponseFactory Negotiated JSON/HTML response

Security

Examples

See examples/ for executable config and file-provider examples.

Development

License

BSD-3-Clause. See LICENSE.md.


All versions of yii3-maintenance-mode with dependencies

PHP Build Version
Package Version
Requires php Version 8.3 - 8.5
ext-filter Version *
psr/http-factory Version ^1.0
psr/http-message Version ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rasuvaeff/yii3-maintenance-mode contains the following files

Loading the files please wait ...