typo3fluid/fluid
TYPO3Fluid is a standalone PHP templating engine extracted from TYPO3 CMS. It provides secure, flexible templates with ViewHelpers, layouts, sections and partials, plus extensibility and caching, making it suitable for MVC apps and reusable component rendering.
UnsafeHTML for raw output—complementing Laravel’s security practices. The template file resolution system (fallback chains, .fluid.* extensions) allows granular control over template overrides, useful for Laravel’s modular package architecture.Fluid\Cache\FileCache) and argument validation optimizations reduce runtime overhead, though Laravel’s Blade is lighter for simple use cases. Fluid’s CLI warmup (bin/fluid warmup) enables pre-compilation, critical for high-traffic Laravel apps.TemplateParser and RenderingContext into the container. The Fluid\View\TemplateView can replace Laravel’s View facade for Fluid-rendered responses.{{{ }}} for CDATA) avoids conflicts with Blade’s {!! !!} or { { } } syntax, enabling hybrid templates if needed.UserComponent with $user = Auth::user() passed as context.symfony/polyfill (resolved in v5.3.1).cache:file, cache:array, or cache:database via PSR-6 adapters.null defaults now enforced) or template naming changes (case sensitivity, .fluid.* extensions). Mitigate via feature flags or gradual rollout.StrictArgumentProcessor (e.g., add @param PHPDoc annotations for union types).App\Exceptions\Handler).view:clear may need extension to purge Fluid’s cache directory.laravel-fluid). Custom packages for service providers, directives, or Livewire/Inertia bridges may be needed.RenderingContext for unit tests; Laravel’s Mockery or Pest may need adapters.<f:for>, <f:if>) or hybrid it with Blade?bin/fluid warmup) viable for CI/CD, or will runtime compilation suffice?config:cache or route:cache?laravel-fluid package)?TemplateParser, RenderingContext, and ViewHelperResolver as Laravel bindings. Example:
public function register(): void
{
$this->app->singleton(\Fluid\Fluid::class, fn() => new \Fluid\Fluid());
$this->app->bind(\Fluid\View\TemplateView::class, fn() => new \Fluid\View\TemplateView());
}
ViewFinder to resolve .fluid.html templates via Fluid’s TemplateResolver.Fluid facade to wrap TemplateView methods (e.g., Fluid::render('template', $data)).Route::get('/user/{user}', fn(User $user) => Fluid::render('user.component', ['user' => $user]));
CardComponent, ModalComponent).FileCache to use Laravel’s storage/framework/cache/fluid directory.bin/fluid warmup with Laravel’s cache:
php artisan fluid:warmup --paths=resources/views --cache=bootstrap/cache/fluid
typo3fluid/fluid:^5.3).TemplateView alongside Blade’s View.@foreach, @if) into Fluid ViewHelpers or components.// Before (Blade)
@component('card', ['user' => $user])
@endcomponent
<!-- After (Fluid) -->
<f:render component="Card" arguments="{user: user}" />
View facade entirely with Fluid’s TemplateView..fluid.html extensions (or leverage fallback chains).<f:for>, <f:if>) differs from Blade’s {!! !!} or @ directives. Provide a migration guide with side-by-side comparisons.{{{ }}}) for CDATA sections to avoid conflicts with Blade’s { { } }.| Blade Directive | Fluid Equivalent |
|---|---|
@foreach |
<f:for> |
@if |
<f:if> |
@include |
<f:render partial="..." /> |
@component |
<f:render component="..." /> |
{user.name}) is stricter than Blade’s {!! $user->name !!}. Use UnsafeHTML for raw output:
<f:variable name="rawHtml" value="{user.name}" type="Fluid\UnsafeHTML" />
symfony/polyfill).How can I help you explore Laravel packages today?