braunstetter/template-hooks-bundle
symfony/twig-bridge).spatie/laravel-twig or custom setup).Templating component), but Laravel’s service container may need adaptation for dependency injection.$this->context) may need Laravel-specific adjustments (e.g., converting Blade data to Twig variables).TemplateHook services may be required.file, redis).app.cp.global-header vs. vendor.x.hook).app.cp.*) map to Laravel’s module/bundle structure?TemplateHook services be registered in Laravel’s container? (e.g., via register() in a service provider).render())?spatie/laravel-twig (official) or a custom bridge for Twig + Laravel.TemplateHook classes.braunstetter/template-hooks-bundle and spatie/laravel-twig.app.header) to validate Twig integration.@include with {{ hook('...') }} for modular sections.app.{module}.{section}).TemplateHook implementations via:
$this->app->bind(TemplateHook::class, function ($app) {
return new BreadcrumbsHook($app->make(Templating::class));
});
$request, $user) to Twig’s context format.{{ hook('app.header') if config('features.hooks') }}).spatie/laravel-twig with Laravel’s service container.resources/views/twig/hooks/).['user', 'menu_items']).TemplateHook classes for each modular section (e.g., HeaderHook, FooterHook).{{ hook('app.header') }}.tinker to inspect hook services and Twig context.php artisan hooks:list
$this->context['user']).{{ hook() }} call triggers service lookup + Twig rendering. Benchmark with:
Cache::remember()).app.header) first.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Hook service not registered | Template renders empty/broken | Default empty template or @error fallback. |
| Twig environment misconfigured | All hooks fail | Health check in AppServiceProvider. |
| Circular hook dependencies | Infinite loop | Depth limit in hook resolution. |
| Context data missing | Hook renders incorrect content | Validate context in TemplateHook::render(). |
| Twig cache corruption | Stale hook output | Clear cache on hook service updates. |
| PHP version incompatibility | Symfony component errors | Pin symfony/templating to Laravel |
How can I help you explore Laravel packages today?