Skip to main content

Blade Analysis

In addition to PHP classes, Prune can detect unused Blade views in Laravel projects. It discovers all your Blade templates, collects every reference to a view, and reports the templates that are never referenced.

Blade analysis is enabled by default and runs alongside class analysis.

How view references are collected​

Prune gathers Blade view references from two sources:

  1. PHP code — view('name') and Route::view('/uri', 'name') calls in the scanned PHP files, plus any extra referencePaths (such as routes/).
  2. Blade templates — directives and component tags inside .blade.php files.

Supported Blade directives and tags​

ReferenceResolves to
@include, @includeIf, @includeFirst, @extends, @component, @eachView name in the first string argument
@includeWhen($cond, 'view'), @includeUnless($cond, 'view')View name in the second argument
<x-alert>, <x-forms.input>, <x-ns::button>components.alert, components.forms.input, …
@livewire('counter'), <livewire:counter>livewire.counter and the Volt component pattern
note

View references are matched on the literal name. Dynamic view names (built from variables) and custom directives are not detected. See Limitations & Risks.

Running Blade analysis​

Because it is on by default, a normal run already includes Blade orphans:

php vendor/bin/prune src

Blade-only mode​

To analyze only Blade views and skip PHP class detection entirely, pass --blade:

php vendor/bin/prune src --blade

This is useful when you only care about template hygiene, or to keep a separate, faster CI step focused on views.

Configuring Blade analysis​

All Blade options live under the blade key in your config file:

parameters:
blade:
enabled: true
viewPaths:
- resources/views
referencePaths:
- routes
excludeViews:
- errors.404
- errors.500
OptionDefaultDescription
enabledtrueEnable Blade view orphan detection.
viewPaths[resources/views]Directories containing Blade templates.
referencePaths[routes]Extra PHP paths scanned for view() / Route::view() calls.
excludeViews[]View names (dot notation) to never report, e.g. errors.404.

Why referencePaths exists​

Route files often reference views without ever being part of paths (you usually don't scan routes/ for orphaned classes). referencePaths lets Prune read those files for view references without adding their contents to the class map — so Route::view('/welcome', 'welcome') keeps welcome.blade.php from being reported as orphaned.

See also​