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.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-14