Mezzio Documentation
website·Indexed 34 days ago
https://docs.mezzio.devDocumentation for Mezzio, a PSR-7 middleware framework. Includes guides on application features, container integration (Aura.Di, Pimple), routing (FastRoute), and specialized components such as mezzio-authentication and mezzio-authentication-oauth2 (v1, v2, v3) for implementing authorization servers and various OAuth2 grants.
What's inside Mezzio
- laminas-servicemanager is a code-driven dependency injection container for Mezzio. It supports lazy-loading of invokable classes, custom factories, abstract factories for identical construction patterns, lazy-loading proxies, delegator factories for altering construction workflows, and interface injection via initializers.
Overview of Mezzio PSR-7 Middleware Framework
v2Mezzio is a minimalist PSR-7 middleware framework for PHP built on Stratigility. It provides a flexible structure that allows developers to choose their preferred tools for routing, dependency injection, and templating. Key features include:
- Routing: Supports multiple routers including Aura.Router, FastRoute, and laminas-router.
- Dependency Injection: Uses PSR-11 Containers to retrieve composed middleware.
- Templating: Optional support for Plates, Twig, and Laminas's PhpRenderer.
- Error Handling: Supports templated error pages and debugging tools like whoops.
- Nested Applications: Allows writing an application and composing it within another, potentially under a separate subpath.
- Simplified Installation: Provides a custom Composer-based installer that prompts for initial stack choices to create a tailored base.
Overview of Mezzio PSR-7 Middleware Framework
v1Mezzio is a minimalist PSR-7 middleware framework for PHP built on Stratigility. It is designed to provide minimal structure, allowing developers to choose their preferred tools for core functionality. Key features include:
- Routing: Supports multiple routers including Aura.Router, FastRoute, and laminas-router.
- Dependency Injection: Uses container-interop for DI containers, allowing all middleware to be retrieved from a composed container.
- Templating: Optional support for Plates, Twig, and Laminas's PhpRenderer.
- Error Handling: Supports templated error pages and debugging tools like whoops.
- Composition: Supports nested middleware applications, allowing an application to be composed within another, optionally under a separate subpath.
- Installation: Provides a custom Composer-based installer that prompts for initial stack choices to create a tailored base installation.
Overview of Mezzio HTTP Basic Authentication
v1Themezzio-authentication-basiccomponent provides an HTTP Basic Authentication adapter formezzio-authentication. This implementation requires both a username and a password, separated by a colon (:), following the standard browser implementation of HTTP Basic credentials.Overview of mezzio-authorization-rbac
mezzio-authorization-rbac is a Role-Based Access Control (RBAC) permission adapter designed for use with the mezzio-authorization component.Overview of Mezzio Body Parsing Middleware
v1Mezzio\Helper\BodyParams\BodyParamsMiddlewareis a PSR-7 middleware that parses request bodies into parameters and returns a new request instance containing them. It uses a strategy pattern to match the requestContent-Typeand parse the body. By default, it supportsapplication/x-www-form-urlencodedandapplication/json(includingapplication/*+json).Overview of mezzio-authorization
mezzio-authorization provides authorization middleware specifically designed for Mezzio and PSR-7 compliant applications.Overview of mezzio-flash messages
Flash messages are self-expiring, session-based messages used to provide feedback to users after a redirect, such as when implementing the Post-Redirect-Get pattern. A message is created during one request and can be retrieved during the immediately following request; after that, the message is automatically removed and no longer available.// Creating a flash message in middleware $flashMessages->flash('form-complete', 'Thank you; your submission was recorded.'); // Retrieving the message on the subsequent request $message = $flashMessages->getFlash('form-complete');Overview of mezzio-hal
v2mezzio-hal provides tools to automate the creation of HAL payloads from PHP objects. It allows developers to model API resources with relational links and embedded child resources. Key components include:
Mezzio\Hal\Link: Value object for relational links.Mezzio\Hal\HalResource: Value object describing an API resource and its links.Mezzio\Hal\HalResponseFactory: Generates PSR-7 responses for HAL resources.Mezzio\Hal\LinkGenerator: GeneratesLinkinstances based on application routes.Mezzio\Hal\Metadata: Maps PHP objects to their HAL representations (e.g., defining which route to use for a 'self' link or which hydrator to use).Mezzio\Hal\ResourceGenerator: Uses metadata to convert PHP objects intoHalResourceinstances.
Overview of available Mezzio Helpers
v3Mezzio provides a set of helper utility classes and middleware to handle common application tasks. Available helpers include:
- Body Params Middleware: For parsing request bodies.
- Content-Length Middleware: (Available since mezzio-helpers 4.1.0) For managing content length headers.
- UrlHelper: For generating URLs.
- ServerUrlHelper: For generating server-specific URLs.
Overview of mezzio-authentication-oauth2
mezzio-authentication-oauth2 provides OAuth2 server authentication middleware designed for use with Mezzio and any PSR-7 compliant applications.Overview of laminas-servicemanager
v3laminas-servicemanager is a code-driven dependency injection container for Mezzio. It supports lazy-loading of invokable classes, custom factories, abstract factories for shared construction patterns, lazy-loading proxies, delegator factories for altering construction workflows, and interface injection via initializers.