debuss-a/awareness-mezzio-template 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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\TemplateRendererAwareInterface
  • Awareness\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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固