Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Fluid Laravel Package

typo3fluid/fluid

typo3fluid/fluid is a standalone PHP templating engine and the rendering core behind TYPO3. It provides secure, logic-light HTML templates with layouts, partials, sections, view helpers, and caching for maintainable server-rendered views.

View on GitHub
Deep Wiki
Context7

TYPO3 Fluid is a powerful, standalone PHP templating engine and the rendering component of TYPO3 CMS. It brings HTML-like templates, automatic output escaping, and a clean separation of logic and presentation to any PHP project—without requiring the full CMS.

  • ViewHelpers for reusable, chainable template logic
  • Layouts, partials, and sections for composable templates
  • Automatic escaping and secure-by-default rendering
  • Expression language and flexible variable access
  • Framework-agnostic integration via Composer
Frequently asked questions about Fluid
Can I use TYPO3Fluid in Laravel without TYPO3 CMS dependencies?
Yes, the standalone package `typo3fluid/fluid` is fully decoupled from TYPO3 CMS. It includes only the templating engine, ViewHelpers, and core rendering logic, making it lightweight and Laravel-ready. You’ll need to configure it via a Laravel Service Provider to integrate with Laravel’s view system.
How do I integrate Fluid templates into Laravel’s view system?
Use a Laravel Service Provider to register Fluid’s compiler and bind it to Laravel’s view resolver. This allows you to render `.fluid.html` files via `return view('fluid::template')` or embed them in Blade files using `@include('fluid::partial')`. The package provides a `TemplateViewHelper` to bridge Fluid’s context with Laravel’s data.
Does Fluid support Laravel’s Livewire or Inertia for reactive UIs?
Yes, Fluid components can be mapped to Livewire/Inertia props using custom ViewHelpers or directives like `@mount` and `@bind`. For example, you can pass Livewire properties to Fluid components via `this->props` and bind them to Fluid’s `{{variable}}` syntax. This enables dynamic UIs without JavaScript-heavy solutions.
What Laravel versions and PHP versions does Fluid v5 support?
Fluid v5 requires **PHP 8.1+** and is compatible with **Laravel 9+**. For older Laravel versions (e.g., 8.x), use Fluid v4.6, which supports PHP 7.4+. Always pin the exact version in `composer.json` to avoid dependency conflicts, especially with Symfony polyfills.
How does Fluid’s performance compare to Blade in Laravel?
Fluid templates are compiled to PHP at runtime (unless pre-compiled), which adds a slight overhead compared to Blade’s native parsing. However, Laravel’s OPcache mitigates this. Benchmark with tools like `laravel-debugbar` to measure compilation latency, especially in high-traffic apps. Pre-compiling templates during deployment can further optimize performance.
Can I migrate from Blade to Fluid incrementally in Laravel?
Yes, Fluid and Blade can coexist. Start by using Fluid for new features or complex components (e.g., admin panels) while keeping Blade for legacy views. Use `@include('fluid::partial')` in Blade files to embed Fluid templates gradually. Tools like `artisan view:clear` help manage cache inconsistencies during migration.
How do I handle XSS risks with Fluid’s UnsafeHTML ViewHelper?
Fluid’s `UnsafeHTML` interface (v4.6+) allows controlled HTML injection by explicitly marking content as trusted. For example, `<f:format.html>{userInput}</f:format.html>` escapes by default, while `<f:format.raw>{userInput}</f:format.raw>` bypasses escaping. Always validate input before using `UnsafeHTML` to mitigate XSS risks.
Are there IDE tools or autocompletion for Fluid ViewHelpers in Laravel?
Fluid lacks native Laravel IDE support, but you can use PHPStorm’s **Fluid plugin** or generate PHPDoc stubs for ViewHelpers. For custom ViewHelpers, annotate them with `@mixin` or `@template` tags to improve autocompletion. Alternatively, tools like **Barryvdh/Laravel-Ide-Helper** can generate stubs for Fluid’s core classes.
How do I cache Fluid templates in Laravel for production?
Leverage Laravel’s caching layer by configuring Fluid’s `TemplateCompiler` to use `file`, `redis`, or `database` cache drivers. Run `php artisan cache:clear` or `php artisan view:clear` to invalidate cached templates. For warmup, use Fluid’s CLI tool (`bin/fluid warmup`) or a Laravel command to pre-compile templates during deployment.
What are the alternatives to Fluid for component-based templating in Laravel?
Alternatives include **Blade with components** (native Laravel), **Livewire/Vue/React** for dynamic UIs, or **PHP-Twig** for a more PHP-centric templating engine. Blade is simpler for small projects, while Twig offers stricter syntax but lacks Fluid’s ViewHelper ecosystem. Fluid stands out for its **component encapsulation** and **TYPO3-proven** architecture, making it ideal for large-scale, reusable UI systems.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource