aura/view
Lightweight PHP view/template system implementing TemplateView and TwoStepView patterns. Uses plain PHP templates (file or closure), supports helpers and sections, and has no userland dependencies. Install via Composer as aura/view.
aura/view is standalone, making it ideal for decoupled architectures or shared libraries.ViewFactory for specific routes).$this->data (like Blade’s $view->share()), but requires manual escaping (unlike Blade’s auto-escaping).@section/@yield via beginSection()/getSection(), but with PHP logic (e.g., conditional sections).View class for unit tests (vs. Blade’s compiled templates).aura/view requires manual escaping (e.g., htmlspecialchars). Risk of XSS if overlooked.Aura.Html for escapers or enforce a custom wrapper (e.g., ViewHelper trait).@foreach). Steeper for frontend teams.@section → beginSection()).extract(), closures)?aura/view for non-Blade templates (e.g., emails, APIs).// app/Providers/AuraViewServiceProvider.php
public function register()
{
$this->app->bind(\Aura\View\ViewFactory::class, function () {
return new \Aura\View\ViewFactory;
});
$this->app->alias(\Aura\View\ViewFactory::class, \Illuminate\Contracts\View\Factory::class);
}
| Blade Directive | Aura.View Equivalent |
|---|---|
@foreach |
foreach ($this->items as $item) |
@section |
$this->beginSection('name') |
@include('partial') |
$this->render('partial') |
@yield |
$this->getSection('name') |
View::share() with $view->setData(['key' => 'value']).Aura\View\ViewFactory to Laravel’s ViewFactory interface.View instances where needed (e.g., controllers).ViewMiddleware to support aura/view alongside Blade.Aura\Html\HelperLocator).laravel-blade-components or livewire.php artisan view:clear).file_put_contents for templates).View instances easily (vs. Blade’s compiled files).file_get_contents + eval).| Risk | Impact | Mitigation |
|---|---|---|
| XSS Vulnerabilities | High (no auto-escaping) | Enforce Aura.Html escapers or middleware. |
| Template Not Found | Medium (runtime errors) | Validate paths in ViewRegistry. |
| Closure Memory Leaks | Low (PHP 8+ GC) | Avoid global closures; use unset. |
| PHP Version Incompatibility | Low (PHP 5.4+) | Pin to PHP 8.x for performance. |
| Team Adoption Resistance | High (Blade familiarity) | Provide migration guides/cheat sheets. |
ViewFactory, templates, data binding).How can I help you explore Laravel packages today?