amajot / plates-catchall-templater
Allows you to render templates without defined routes/actions as a kind of catch-all in Zend Expressive
Installs: 1 759
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^5.3 | ^7.0
- psr/http-message: ^1.0
- zendframework/zend-diactoros: ^1.4
- zendframework/zend-expressive-platesrenderer: ^1.3.1
Requires (Dev)
- phpunit/phpunit: ~4.0
- squizlabs/php_codesniffer: ~1.5
This package is not auto-updated.
Last update: 2022-07-23 16:15:38 UTC
README
middleware that will render templates without predefined routes or actions
Installation
Install this library using composer:
$ composer require amajot/plates-catchall-templater
Add a factory in dependencies.global.php
Amajot\CatchAllTemplateRenderer\CatchAllTemplateRenderer::class => Amajot\CatchAllTemplateRenderer\CatchAllTemplateRendererFactory::class,
Add the Middleware in the pipeline before the 404 handler
use Amajot\CatchAllTemplateRenderer\CatchAllTemplateRenderer; ... // At this point, if no Response is return by any middleware, the // NotFoundHandler kicks in; alternately, you can provide other fallback // middleware to execute. $app->pipe(CatchAllTemplateRenderer::class); $app->pipe(NotFoundHandler::class);