DBM Template Engine
The documentation is constantly evolving and updated alongside the project's progress. Since it is developed in parallel with the code, some sections may temporarily refer to earlier versions of the system-these are gradually adapted to the current state of the application. If you notice any outdated information, please report it or open an Issue / Pull Request.
Documentation
# DBM Template Engine
The framework template engine compiles supported .phtml directives into cached PHP artifacts. It is designed to keep the familiar PHP environment while adding includes, filters, and layout blocks. Rendering is coordinated through TemplateEngine; controllers commonly access it through BaseController::render().
# Main components
TemplateEnginecoordinates template lookup, compilation, cache, and rendering.TemplateCompilerconverts supported directives to PHP.FilterExtensionregisters expression filters.TemplateCachewrites and clears compiled artifacts.TemplateRuntimemanages block output and partial rendering.- View providers/extensions register runtime features and defaults.
The application bootstrap configures template and cache roots. Ensure the PHP process can write to the configured cache directory when caching is enabled.
# Template syntax
{{ $value }}
{{ $value|upper|escape }}
{{ $value|raw }}
{% if ($enabled): %} ... {% endif %}
{% foreach ($items as $item): %} ... {% endforeach %}
{% include 'card.phtml' with { 'item': $item } %}
{% extends 'layout.phtml' %}
{% block content %} ... {% endblock %}
{% yield content %}
Normal output is escaped by the compiler. raw deliberately bypasses escaping; use it only when content has been safely prepared. Block inheritance lets a child template fill named sections of a parent layout. Partials can receive local variables through with.
# Filters
The compiler includes filters such as escape/e, raw/safe, upper, lower, trim, length, nl2br, strip, json, url, join, number, date, and raw_allowed, subject to the current registered extension set. Applications can register custom filters through the filter extension. Verify exact signatures in the source before depending on a filter in shared templates.
# Diagnostics
Compilation and cache failures use framework exceptions and are handled by the configured exception pipeline. Development/debug options can retain diagnostic artifacts or run syntax checks depending on the active engine configuration. Do not suppress filesystem or compilation errors globally; make cache directories writable and inspect the original exception.
For rendering examples see Templates. For current configuration and source details, use the framework view provider as the authority.