aura/html
HTML escapers and helpers for any PHP template/view layer, including tag builders and form input helpers. Easy to use via a HelperLocatorFactory; built-in helpers escape values appropriately and you can register custom helpers via the HelperLocator.
HtmlEscaper) mitigate XSS risks, complementing Laravel’s built-in e() helper but offering granular control (e.g., custom context rules).aura/html) + autoloading via Laravel’s composer.json requires no manual configuration.e() helper by binding the HtmlEscaper to the service container (e.g., Html::escapers()).Html::input(), Html::select()) that can coexist with Laravel Collective’s Form package or serve as a lightweight alternative.e(), htmlspecialchars(), and Form package. Risk of confusion if not clearly scoped (e.g., "use Aura for advanced escaping rules").e($var) vs. Html::escapers()->html($var))?markbaker/matrix)?@escapes) or service container bindings.HtmlEscaper and helpers as singletons for global access.htmlspecialchars() with Html::escapers()->html() in validation/error messages.Phase 1: Escaping
e($var) with Html::escapers()->html($var) in Blade templates.HtmlEscaper to the container in AppServiceProvider:
$this->app->singleton('html.escaper', fn() => new \Aura\Html\HtmlEscaper());
Blade::directive('escapes', fn($expr) => "<?php echo app('html.escaper')->html($expr); ?>");
Usage: @escapes($var) in Blade.Phase 2: Form Helpers
<input>/<select> generation with Html::input()/Html::select().Html::input('text', 'username', $user->username, ['class' => 'form-control']);
FormRequest for CSRF protection.Phase 3: Validation
Html::escapers()->html() in AppExceptionHandler for error messages to ensure consistency.@escapes($dynamicVar)).Form package).| Priority | Task | Dependencies |
|---|---|---|
| 1 | Install aura/html |
Composer |
| 2 | Bind HtmlEscaper to container |
Laravel 8.50+ (container) |
| 3 | Replace e() with @escapes |
Blade directives |
| 4 | Migrate form helpers | Phase 1 validation |
| 5 | Update tests | All integrations |
html() vs. attribute()).Html::escapers()->method()) is intuitive.@escapes vs. e()).HtmlEscaper::getContext() to debug context mismatches.Html::input()) could reduce view rendering time.e() or Laravel Collective.| Risk | Mitigation | Detection |
|---|---|---|
| XSS Vulnerabilities | Use strict escaping contexts. | Security scans (e.g., PHPStan). |
| PHP 8.4 Incompatibility | Fork/patch or upgrade PHP. | CI checks (e.g., phpunit --version). |
| Blade Directive Conflicts | Name directives uniquely (e.g., @auraescapes). |
Test suite with edge cases. |
| Form Helper CSRF Issues | Ensure helpers include {{ csrf_field() }}. |
Manual review of generated HTML. |
htmlspecialchars() directly may need refactoring.How can I help you explore Laravel packages today?