- How do I install coolms/dtmpl in a Laravel application?
- Install it with composer require coolms/dtmpl, but note the package requires PHP ^8.5, which blocks installation on most current Laravel applications. There is no Laravel service provider, facade or config file, so you wire it yourself: bind DtmplEngine as a singleton in a service provider and pass it a FilesystemTemplateLoader pointing at your template directory. No dtmpl-laravel package exists, so all Laravel glue code is yours to write and maintain.
- Does coolms/dtmpl support Laravel 11 or Laravel 12 and PHP 8.4?
- The package declares PHP ^8.5 as a hard requirement, while current Laravel releases target PHP 8.2 through 8.4, so a standard Laravel app cannot install it without upgrading the runtime ahead of the framework's supported matrix. There is no declared Laravel version constraint because there is no Laravel integration layer at all. You can attempt a fork pinned to PHP 8.3 with a compatibility patch, but you then own that patch and its maintenance.
- Is there a Laravel service provider or facade for DTMPL?
- No. DTMPL is explicitly framework-optional, which in practice means framework-unintegrated: no service provider, no facade, no publishable config, no Blade-style directive layer. The only first-party integration is coolms/dtmpl-bundle for Symfony, which registers the engine, loader chain, widget registry and constant providers. In Laravel you replicate that wiring by hand in your own provider.
- How does the DTMPL sandbox work and is it safe for author-supplied templates?
- The README states templates read only what the context gives them: no PHP execution, no filesystem access and no arbitrary calls. That is the package's strongest argument, but it must be independently verified because a template engine is an injection surface. Review the AST evaluator and the widget boundary before trusting it with untrusted content, since a widget is likely a trusted PHP callback with full application access, which determines whether the sandbox story holds once you extend it. There is no third-party security audit or community corpus to lean on.
- How do I register custom widgets and filters in DTMPL from Laravel?
- Widgets, filters, constants and loaders are the documented extension seams the host application fills. In Symfony the bundle registers the engine, loader chain and widget registry for you; in Laravel you construct the engine with your loader and register widgets from a config array inside your service provider. Filters can be wired to your application services at that same point. Keep the registry explicit and small, because every widget you expose widens the trust boundary described by the sandbox claims.
- Can I use Laravel's cache with DTMPL given its PSR-6 dependency?
- DTMPL depends on psr/cache, which is PSR-6, while Laravel's cache repository implements PSR-16, so you need a PSR-6 adapter to feed the engine's caching layer. It also pulls symfony/property-access and symfony/translation-contracts, which are small but not native to a Laravel install. The README does not document the cache key format or invalidation contract, so confirm how compiled templates are keyed before relying on cache clearing in production.
- What does DTMPL syntax look like and how is it different from Blade?
- Every tag uses the form {keyword:argument} and blocks close with {endkeyword} rather than a slash form, so you write {if:page.isPublished} ... {endif} and {loop:posts:post} ... {endloop}. Variables render with {var:page.title}, filters chain with spaces such as {var:page.title uppercase truncate:80}, assignments use {def:total=cart.count}, and comparisons use a single = plus !=, <, <=, > and >=. It is deliberately not PHP-like, because the target author is a designer or content editor rather than a Laravel developer.
- Is DTMPL a good alternative to Blade for Laravel views?
- Only for a specific shape: content-heavy or multi-tenant applications with a CMS surface where non-developers author templates and PHP inside templates is unacceptable. For ordinary application views it is a poor fit, because Blade gives zero-cost integration, a component model and first-party documentation, making the switching cost indefensible. If the requirement is genuinely designers shipping templates without touching PHP, DTMPL is defensible; otherwise stay with Blade.
- How do I test DTMPL templates and what happens on a template error?
- The README, docs and changelog do not describe test coverage, a CI matrix beyond the badge, or runtime error behaviour, so establish both before production. Test malformed and adversarial input yourself: nesting depth, unclosed blocks, bad filter arguments and whitespace control are where hand-rolled lexer and parser stacks usually have edge cases. Decide explicitly whether you want exceptions, partial renders or blank output, and assert that behaviour in your own integration tests around the engine.
- Who maintains coolms/dtmpl and is it actively supported?
- The package shows zero stars and zero dependents, with no Stack Overflow corpus or third-party tutorials, so documentation and source are effectively your only support channels. That points to a single-author or small-team project with an unproven semver, deprecation and release cadence, and any defect becomes an internal fork or a vendor conversation. Before adopting it, ask whether PHP 8.5 is a hard floor or an untested ceiling, what the real CI range is, and whether there is a commercial or roadmap commitment behind it.