Download the PHP package contenir/maintenance-mezzio without Composer

On this page you can find all versions of the php package contenir/maintenance-mezzio. 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 maintenance-mezzio

contenir/contenir-maintenance-mezzio

Formerly contenir/maintenance-mezzio; the old package is abandoned in favour of this one.

Continuous Integration codecov

Mezzio adapter for contenir/contenir-maintenance.

When the admin (Contenir CMS) toggles maintenance mode, this adapter's PSR-15 middleware answers every request in the consuming Site with a 503 response, until the flag is cleared.

Requirements

The 0.x releases remain available from the 0.x branch and v0.* tags; see UPGRADE-2.0.md.

Install

Wire-up

1. Register the ConfigProvider

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

2. Pipe the middleware early

Pipe it straight after ErrorHandler and ServerUrlMiddleware, and before anything that can answer a request on its own, in particular any page-cache middleware. A cache piped ahead of it would keep serving stored pages while the site is meant to be down. The 503 carries Cache-Control: no-store, so caches further down the line will not store it either.

3. Point at the shared state file

file defaults to config/autoload/maintenance.local.php under the working directory, which is the file the admin writes for a Site in the standard layout. With nothing else set, the middleware returns the bundled 503 page with the admin's message whenever maintenance is active.

Why the file is read on every request

The middleware asks the repository for the state on every request rather than reading $config['maintenance']['state']. Mezzio caches the merged config in production (config/autoload/*.local.php included), so state read from config would be frozen at the moment the cache was built, and the admin's toggles would be ignored until someone cleared it. Reading the small PHP state file costs one include, which opcache serves from memory. If the Site runs with opcache.validate_timestamps=0 in a different PHP pool from the admin, the admin's write cannot invalidate the Site's cached copy; leave timestamp validation on for that file's directory, or reset opcache on toggle.

To read the state from somewhere else, register a service for Contenir\Maintenance\MaintenanceRepositoryInterface; when one exists it is used instead of the file, and file is ignored.

4. (Optional) Bypass for operators

bypass is any callable that takes the ServerRequestInterface and returns bool; only a strict true lets the request through. Prefer a static method callable, as above, over a closure: Mezzio cannot write a closure into its config cache. The bypass sees the request as it is when the middleware runs, so request attributes such as an authenticated user are only there if the middleware that sets them is piped ahead of this one.

5. (Optional) Customise the response body

body_template_path may name any file: .phtml and .php files are evaluated as PHP once, when the middleware is built, and anything else is read as-is. The bundled templates/maintenance.phtml is a good starting point. For a short body, set body_template to an inline string instead; it wins over body_template_path.

Either way the result is a sprintf format string. It receives two arguments, and any other % must be written as %%:

Placeholder Value
%s or %1$s The HTML-escaped message
%2$s since, when maintenance started, as ISO 8601 (2026-05-05T03:14:15+00:00); an empty string when the state has no since or it could not be parsed

A template that only uses %s is unaffected by since. To show it:

If you need anything more elaborate (full layout, template renderer, translation), replace the MaintenanceMiddleware service with your own factory.

Options

Key Default Meaning
file getcwd() . '/config/autoload/maintenance.local.php' State file written by the admin
retry_after 600 Seconds sent as the Retry-After header
bypass null callable(ServerRequestInterface): bool
body_template unset Inline sprintf body; wins over the path
body_template_path bundled templates/maintenance.phtml Body template file; null uses a minimal inline body

Public API

Class Purpose
ConfigProvider __invoke() and getDependencies() register the middleware factory. It adds no maintenance key, so the site's config is the only source of options. defaultBodyTemplatePath() returns the bundled template's absolute path.
Factory\MaintenanceMiddlewareFactory Builds the middleware from config['maintenance'] (options above). DEFAULT_STATE_FILE is the state file path relative to the working directory. Invalid options throw RuntimeException when the container builds the middleware.
Middleware\MaintenanceMiddleware The PSR-15 middleware. DEFAULT_RETRY_AFTER (600) and DEFAULT_BODY_TEMPLATE (a minimal inline page) are its defaults.

Factory\BodyTemplateLoader is internal.

The middleware can also be built by hand, for example in a site's own factory:

When the repository reports maintenance as active and the bypass does not return true, process() returns a 503 text/html; charset=utf-8 response with Retry-After and Cache-Control: no-store. The admin's message is HTML-escaped and put in place of the template's %s, and since in place of %2$s. Otherwise the request goes to the next handler.

Development

The QA toolchain is contenir/contenir-qa-tools. Mago is a standalone binary, installed separately (brew install mago).

License

MIT. See LICENSE.


All versions of maintenance-mezzio with dependencies

PHP Build Version
Package Version
Requires php Version ~8.3.0 || ~8.4.0 || ~8.5.0
contenir/contenir-config Version ^2.1
contenir/contenir-maintenance Version ^2.1
laminas/laminas-diactoros Version ^3.0
psr/container Version ^1.1 || ^2.0
psr/http-message Version ^1.1 || ^2.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 contenir/maintenance-mezzio contains the following files

Loading the files please wait ...