Overview¶
Why this exists¶

Blade is the right answer for most Laravel apps, but a few situations push teams towards Smarty:
- Migrating a legacy PHP app into Laravel where thousands of
.tpltemplates already exist and rewriting them all to Blade is not on the table. - Designer / non-PHP authors who already know Smarty's syntax and modifier pipeline (
{$var|truncate:80|escape}). - Stricter sandboxing — Smarty's security policy can lock down what templates are allowed to do, which is harder to retrofit on Blade.
- Per-team preference for Smarty's tag style and inheritance model.
This package wires Smarty into Laravel's view machinery so you keep using view('foo', $data) from controllers and view() returns a View instance that renders Smarty under the hood.
How it works¶
- The
.tplextension is registered ahead of.blade.phpon Laravel's view finder, soview('welcome')resolveswelcome.tplfirst and falls back towelcome.blade.phpif no Smarty template exists. Both engines coexist — this is a soft replacement, not a forced rewrite. - A
SmartyEngineimplementsIlluminate\Contracts\View\Engineand is registered on theview.engine.resolverfor thesmartyengine name. - A
SmartyFactorybuilds a configuredSmartyinstance per resolver invocation, wired up with the configured compile/cache directories, caching settings, and plugin paths. - A
BridgedSmartysubclass overridesdoCreateTemplate()so that every sub-template loaded via{extends}or{include}fires Laravel'screating:andcomposing:events with a realIlluminate\View\Viewinstance. This means view composers andbarryvdh/laravel-debugbar's view collector see the full template tree on every render — same surface Blade exposes, even when Smarty's compile cache is warm. - The same
doCreateTemplate()hook injects aLineTrackingCompileronto every SmartyTemplatevia reflection, so runtime errors raised inside a.tplbody can be walked back to the originating tag — see Template error source mapping.