componenta/templater-app 问题修复 & 功能扩展

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

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

componenta/templater-app

Composer 安装命令:

composer require componenta/templater-app

包简介

Componenta application integration for template rendering

README 文档

README

Application integration for componenta/templater. It registers the template engine, renderer, bootloader, static View helper, and global view() function.

Installation

composer require componenta/templater-app

The package exposes Componenta\Templater\App\ConfigProvider through Composer metadata and autoloads src/functions.php.

Registered Services

Componenta\Templater\App\ConfigProvider registers:

Service or key Registration
Componenta\Templater\Engine EngineFactory, using template config and PathResolverInterface.
Componenta\Templater\RendererInterface RendererFactory, wrapping the registered engine.
ViewBootloader Autowired bootloader.
AppConfigKey::BOOTLOADERS Adds ViewBootloader so View receives the renderer during application boot.

Configuration

Template settings are read from the renderer config section:

use Componenta\Templater\App\ConfigKey;

return [
    ConfigKey::ROOT => [
        ConfigKey::TEMPLATES_DIR => 'templates',
        ConfigKey::EXTENSION => 'phtml',
        ConfigKey::FOLDERS => [
            'mail' => 'templates/mail',
        ],
        ConfigKey::FUNCTIONS => [
            'asset' => static fn(string $path): string => '/assets/' . ltrim($path, '/'),
        ],
    ],
];

Paths are resolved through PathResolverInterface. The default template directory is templates, and the default extension is phtml.

Runtime Behavior

ViewBootloader runs in HTTP and CLI scopes. It gets RendererInterface from the container and installs it into View::setRenderer(). After boot, code can call:

echo view('welcome', ['name' => 'Componenta']);
echo Componenta\Templater\App\View::render('welcome');

Calling view() or View::render() before the bootloader runs throws LogicException.

Boundary

The package wires templates into an application. The renderer implementation itself lives in componenta/templater; path resolution lives in componenta/path-resolver.

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-14