isaadsalman/section-view
isaadsalman/section-view is a Laravel package for managing reusable Blade view sections. Define named sections, render them individually, or compose them into layouts to keep page fragments organized and easy to reuse across your application.
section-view is a Laravel package for composing a single view out of discrete, individually-maintainable "sections" rather than one monolithic Blade template. v1.0.0 is the first tagged stable release, so treat it as a green-field dependency — there is no migration path from an earlier version to worry about, and no breaking-change history to read yet.
Install and publish:
composer require isaadsalman/section-view
php artisan vendor:publish --tag=section-view-config
The package registers via Laravel package auto-discovery, so no manual providers entry should be needed. Confirm it appears in php artisan about / php artisan vendor:publish output before going further — if the publish tag is missing, auto-discovery did not fire and you are likely on a cached config or a stale lockfile.
Where to look first, in order:
config/section-view.php — the section registry is almost always config-driven. Read this before writing any code; it dictates naming, ordering, and the default view resolution strategy.src/ root for the service provider and the section contract/abstract class — this tells you whether sections are plain Blade paths, class-based, or both.README usage block for the single facade/helper call that renders a composed view.First real use case: a marketing or CMS-driven page where the layout is fixed but the block sequence varies per page (hero, feature grid, testimonials, CTA). Instead of one 300-line Blade file with @includes and conditionals, you register each block as a section and render the page by listing section keys in order. Start by converting one existing page to this pattern — not your whole app — so you can compare the output byte-for-byte against the old template.
Config-registry pattern. Declare sections in config/section-view.php as a keyed map (hero, features, cta) pointing at a view name or a section class. Callers then reference only the key, which keeps templates free of hard-coded view paths and makes sections swappable per environment or per tenant.
Class-based sections. For sections with data requirements, back each key with a class exposing a data()/view() pair. Inject repositories or query builders there rather than in the controller — this is where the package earns its keep, because each section owns its own query and you avoid the "controller loads 14 unrelated collections" problem.
Ordering as data. Store the section order in the database (a sections JSON column on the page model) and pass the ordered key list to the render call. This gives editors reordering without deploys. Validate the incoming keys against the config registry and drop unknown ones rather than letting them throw.
Layout integration. Wrap the composed output in your normal layout: have the package render the inner content and @extends/<x-layout> around it, or render into a named Blade section. Avoid nesting the package's renderer inside another package renderer — resolution order becomes hard to reason about when debugging.
Partial caching. Because sections are discrete, they are ideal cache units. Cache per section key plus a hash of its inputs, and flush on model save via observers. This is usually a bigger win than caching the whole page, since one section changing does not invalidate the rest.
Testing. Assert on the rendered HTML per section rather than snapshotting the whole page: $this->view('sections.hero')->assertSee(...). For integration, one feature test per page that asserts each expected section key appears in the output in the configured order catches most ordering regressions.
Inertia / Livewire boundaries. If you use either, keep the section composition server-side and treat the composed HTML as the shell; don't try to make individual sections into Livewire components unless the package explicitly supports it, or you will end up with two competing render pipelines.
"isaadsalman/section-view": "1.0.0" rather than ^1.0. A first stable tag often shakes out API rough edges in 1.0.x; you want upgrades to be a deliberate, reviewed commit.view:cache. In production deploys, run php artisan view:clear after config:cache if you change the section registry, otherwise removed sections linger and new ones 500.config().data() returns an empty collection usually renders nothing rather than erroring. Add a debug flag or a @dump wrapper in local to confirm a section actually executed instead of assuming it did.json_decode(..., true) on an object yields an associative array where array_map preserves keys but sort does not. Normalise to a plain list before passing it in.src/. Look for a bound singleton/manager you can resolve and extend (custom resolvers, per-section caching decorators). That binding is your safest hook for tenant-specific behaviour; subclassing the service provider is not.card will shadow x-card. Prefix section component names or use the view-path resolver to keep namespaces separate.How can I help you explore Laravel packages today?