jaem3l/template-bundle
jaem3l/template-bundle is a Laravel/PHP package that provides a convenient template bundle for organizing and rendering reusable templates. It simplifies template management and integrates smoothly with Blade, helping you keep view logic clean, consistent, and easy to maintain.
Start by installing the package and checking what v1.1.0 actually ships:
composer require <vendor>/<package>
Then look at, in order:
CHANGELOG.md for the new TemplateController.__invoke) or exposes named actions.config/<package>.php) and whether it needs publishing with php artisan vendor:publish.The first practical use case is replacing a closure-based template route with the new controller:
// routes/web.php
use Vendor\Package\Http\Controllers\TemplateController;
Route::get('/pages/{page}', TemplateController::class)->name('pages.show');
Create or point the controller at a view (for example resources/views/pages/{page}.blade.php), then visit /pages/about. If the controller expects a specific route parameter name or a configured view namespace, match that before adding your own logic.
Because this is a new controller in a minor release, verify the exact route parameter and view-resolution contract from the package source rather than assuming it mirrors other templating packages.
Use the controller as a thin routing layer. Let TemplateController resolve and render templates, and keep authorization, redirects, and data loading in middleware, route defaults, or a dedicated controller that delegates to it.
Route-per-template pattern. For small marketing or CMS-style sites, register explicit routes rather than a catch-all:
Route::get('/about', TemplateController::class)->defaults('template', 'pages.about');
Route::get('/pricing', TemplateController::class)->defaults('template', 'pages.pricing');
Confirm whether the controller reads route defaults, a route parameter, or a config mapping.
Parameterised pages. If the controller accepts a {page} parameter, constrain it to avoid collisions with other routes:
Route::get('/pages/{page}', TemplateController::class)
->where('page', '[A-Za-z0-9\-]+')
->name('pages.show');
Middleware integration. Apply auth, locale, or cache headers at the route level so the controller stays reusable:
Route::middleware(['web', 'auth'])->group(function () {
Route::get('/docs/{page}', TemplateController::class);
});
Testing. Use Laravel feature tests to assert the rendered view and status code. If the controller resolves templates dynamically, include a test for a missing template so you know whether it returns 404 or throws.
Incremental adoption. Keep existing Route::view() and closure routes in place, and migrate one route at a time to TemplateController. This is especially useful if the controller adds behaviour such as fallback templates, metadata, or theme resolution.
TemplateController was added. Check the controller signature and README before relying on route defaults, parameter names, or view namespaces.{template}, {page}, or {slug}). A mismatch usually surfaces as a missing argument or a 404, not an obvious exception.view().php artisan view:clear and php artisan config:clear. If the controller caches resolved templates, check whether the package exposes a cache key or TTL.composer.json until the controller’s API stabilises: "<vendor>/<package>": "^1.1".How can I help you explore Laravel packages today?