vusys / laravel-smarty
Replace Blade with Smarty as the default Laravel template engine.
Requires
- php: ^8.1
- illuminate/contracts: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- illuminate/view: ^10.0|^11.0|^12.0|^13.0
- smarty/smarty: ^5.4
Requires (Dev)
- driftingly/rector-laravel: ^2.0
- infection/infection: ^0.33 || ^0.34
- larastan/larastan: ^2.9 || ^3.0
- laravel/pennant: ^1.0|^2.0
- laravel/pint: ^1.0
- orchestra/testbench: ^8.1|^9.0|^10.0|^11.0
- phpunit/phpunit: ^10.5.32|^11.5|^12.0
- rector/rector: ^2.0
Suggests
- laravel/pennant: Required for the {feature} block and the feature_active modifier
Provides
None
Conflicts
None
Replaces
None
- dev-master
- v0.22.0
- v0.21.1
- v0.21.0
- v0.20.10
- v0.20.9
- v0.20.8
- v0.20.7
- v0.20.6
- v0.20.5
- v0.20.4
- v0.20.3
- v0.20.2
- v0.20.1
- v0.20.0
- v0.19.0
- v0.18.0
- v0.17.0
- v0.16.0
- v0.15.0
- v0.14.0
- v0.13.0
- v0.12.0
- v0.11.0
- v0.10.0
- v0.9.0
- v0.8.0
- v0.7.0
- v0.6.1
- v0.6.0
- v0.5.1
- v0.5.0
- v0.4.0
- v0.3.0
- v0.2.0
- v0.1.0
- dev-docs-pages-actions
This package is auto-updated.
Last update: 2026-10-17 09:31:53 UTC
README
Replace Blade with Smarty 5 as the default view engine in a Laravel application.
📚 Full documentation: vusys.github.io/laravel-smarty
Requirements
- PHP
^8.1 - Laravel
^10 | ^11 | ^12 | ^13 smarty/smarty^5.4
Installation
composer require vusys/laravel-smarty
The service provider is registered automatically via package discovery.
Publish the config (optional):
php artisan vendor:publish --tag=smarty-config
That writes config/smarty.php.
To customise the bundled paginator templates, publish them with:
php artisan vendor:publish --tag=smarty-pagination-views
That copies the pagination::* presets (Tailwind, Bootstrap 3/4/5, Semantic UI, and their simple variants) into resources/views/vendor/pagination/, where your edits override both the package's bundled .tpl and Laravel's framework Blade views. See docs/pagination.md for details.
Quick start
Create resources/views/welcome.tpl:
<!doctype html> <html lang="en"> <head><title>{$title}</title></head> <body> <h1>Hello, {$name}!</h1> </body> </html>
{$var} output is HTML-escaped automatically (escape_html is on by default), matching Blade's {{ }} — no |escape needed. Use {$var nofilter} where you deliberately want raw output.
Render it like any Laravel view:
Route::get('/', fn () => view('welcome', [ 'title' => 'Home', 'name' => 'World', ]));
Smarty resolves before Blade, so a welcome.tpl overrides an existing welcome.blade.php for the same view name.
Documentation
| Topic | What's in it |
|---|---|
| Overview | Why this package exists; how the Smarty bridge plugs into Laravel's view machinery. |
| Quick start | First template, route, and a {extends} inheritance example. |
| Configuration | Every config/smarty.php key, plus the SmartyFactory::configure() hook for advanced wiring. |
| Security policy | The shipped Balanced / Strict policies and when to use each. |
| Built-in plugins | {auth}, {can}, {feature}, {route}, {lang}, {vite}, number modifiers, and the rest. |
| Auto-shared wrapper objects | $auth, $request, $session, $route, $errors and their reserved-key behaviour. |
| Pagination | Bundled paginator presets and how to publish them. |
| Custom plugins | File-based plugins, class-backed discovery, and the discovery cache. |
| Artisan commands | smarty:optimize, the clear-* commands, and the plugin discovery cache commands. |
| Laravel integration | View composers, Debugbar/Telescope, and .tpl source-line error mapping. |
| Troubleshooting | Stale compiles after deploys, ReservedTemplateVariable, escaping surprises, Octane notes. |
| Development | Running tests, static analysis, code style. |
License
MIT.