debuss-a/awareness-mezzio-template
最新稳定版本:1.0.0
Composer 安装命令:
composer require debuss-a/awareness-mezzio-template
包简介
A set of interfaces and traits to make your classes AWARE, just like JCVD.
README 文档
README
debuss-a/awareness-mezzio-template provides a focused "aware" interface and trait for Mezzio template rendering.
It lets your classes declare that they need a Mezzio\Template\TemplateRendererInterface through a standard setter, making setter injection simple and consistent.
What is included?
This package exposes:
Awareness\TemplateRendererAwareInterfaceAwareness\TemplateRendererAwareTrait
The interface defines a setTemplateRenderer() method, and the trait provides a ready-to-use implementation with a $templateRenderer property.
Why use it?
This package is especially useful when your container supports inflectors or automatic setter injection.
Benefits include:
- ✅ A clear contract for classes that need a template renderer
- ✅ Reusable setter injection without duplicating boilerplate
- ✅ Easy integration with containers that can target an interface
- ✅ Simple testing by injecting a mocked or stubbed renderer
Basic usage
use Awareness\TemplateRendererAwareInterface; use Awareness\TemplateRendererAwareTrait; class PageAction implements TemplateRendererAwareInterface { use TemplateRendererAwareTrait; public function renderHomepage(): string { return $this->templateRenderer->render('app::home'); } }
Using with an inflector
With a container such as League Container, you can automatically inject the Mezzio template renderer into any class implementing TemplateRendererAwareInterface.
use Awareness\TemplateRendererAwareInterface; use League\Container\Container; use Mezzio\Template\TemplateRendererInterface; $container = new Container(); $container->add(TemplateRendererInterface::class, AppTemplateRenderer::class); $container->inflector(TemplateRendererAwareInterface::class) ->invokeMethod('setTemplateRenderer', [TemplateRendererInterface::class]);
Installation
composer require debuss-a/awareness-mezzio-template
Requirements
- PHP 8.0 or higher
mezzio/mezzio-template^3.0
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-09